I installed the jdk 5(jdk-1_5_0_08-windows-i586-p) in my computer and set
the path variable to the bin directory and class path to MyProgram. Then I wrote a small Hello program and compiled. Compilation was successful but when I tried to run the program,I got the following :
C:\MyProgram>
java MyClass
Exception in
thread "main" java.lang.UnsupportedClassVersionError: MyClass (Unsupported major.minor version 49.0)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:493)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:11
1)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:248)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:286)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
C:\MyProgram>
My Hello world program is as follow:
public class MyClass{
public static void main(
String[] args){
System.out.println("Hello World");
}
}
I don't get any error when I use jdk1.4. can someone tell me why ?