I have jdk 1.6 installed in my system.
It was doing well initially.All of a sudden there is an error when trying to run even a small java program
the error is as follows.
Exception in thread "main" java.lang.UnsupportedClassVersionError:TDemo<Unsupported major.minor version 50.0>
at java.lang.ClassLoader.defineClass0(Native Method)
what reason might have caused the error?
thanks for the reply in advance
Sebastian Janisch wrote:I'm pretty sure it means you compiled your code with Java 5 and try to run it with Java 6.
You probably mean that the other way around: the code was compiled with Java 6, and you're trying to run it with Java 5.
Java is downward compatible: newer versions can run class files compiled with older versions. But it is not upward compatible - older versions cannot (normally) run class files compiled with newer versions.
Compile your code with Java 5 if it needs to run on a Java 5 JRE.
I compiled it in the command prompt and tried to run it as soon as it is compiled
I dint make any changes of the version.
The same code is running successfully when i tried to run it in netbeans IDE instead of command prompt.
Vinnibabu singu wrote:It is giving java 1.4
But I installed java 1.6 and my control panel confirms it.
Why might be the problem?
Your OS may have Java preinstalled -- and you didn't set the PATH variables correctly, so it is running the default one. As for NetBeans, the IDE makes sure it uses the same compiler and JVM version.