.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
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.
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.
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.
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