.java file compiling but not executing in jdk6

Using javac in jdk6 I can compile a .java file but cant executing the same using java command from my own directory. I can still compile and execute the same file from jdk\bin directory. I am using windows XP Home. While executing the .java file from my own directory, it fires a message: "The Java class could not be loaded. java.lang.UnsupportedClassVersionError: Myfilename (Unsupported major.minor Version 50.0)". i have set path in environment variable as "C:\sun\sdk\jdk\bin" where jdk placed in sun\sdk.

Please help me to solve the problem

[559 byte] By [Arun@Globala] at [2007-11-27 1:24:36]
# 1
I believe that problem is a result of compiling with one version of java and trying to run with a different version. make sure your classpath is set up correctly.
floundera at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 2
Maybe you added the bin directory to the path after the directory that points to whatever other version of the JVM you have on your drive.Or maybe you intended to add that directory to the path, but actually added it to the classpath. It's a common mistake.
paulcwa at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 3

Tahnks for your response. I am compiling the programe in jdk6 and executing in the same. Please give me the path and class path for both user and system environment vriable. My jdk's bin path is as follows:

c:\sun\sdk\jdk\bin

I am compiling and trying to executing the programme from my own directory i.e. c:\jp

Please reply.

Arun@Globala at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 4

This isn't information we can give you. You have to set it up based on your system.

Do you understand how execution paths work? There's a list of filesystem paths, separated by a semicolon or a colon depending on the system, all concatenated into one big string. The entries earlier in the string are looked in first.

So if your path has this:

c:\Windows\java;c:\sun\sdk\jdk\bin

Then if you type "java" from the command line, the Windows one would be executed, not the JDK 6 one.

paulcwa at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 5

Thanks. So you sujjest to set the path environment variable in user variable as C:\sun\sdk\jdk\bin at the begining of the path not at the end. It is for your kind information that I using the jdk6 which comes with java_ee_sdk-5_02-windows file from sun portal. Please give the setting for classpath also.

Thanks againg.

Arun@Globala at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 6
How about explicitly telling the path of the java and javac ?c:\j2sdk1.4.0_12\bin\javac YourProgram.javac:\j2sdk1.4.0_12\bin\java YourProgramin your case, it would be C:\sun\sdk\jdk\bin
rym82a at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 7

Finally I got the solve. Basically it was a problem of two version of java environment available in the system. So, I have set the path in user and system variable as C:\sun\sdk\jdk\bin at the begining of both path's existing paths and set classpath in system variable as "." and classpath in uservariable as " ". Anybody face such problems can get this process as a help.

Thanks all of you.

Arun

Arun@Globala at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...
# 8
Good work.And you should assign duke stars to people helped you.
rym82a at 2007-7-12 0:16:06 > top of Java-index,Java Essentials,New To Java...