Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (9.5k points)

Below is the exception I get in my JDK7 when I try to compile a simple ‘hello world’ program:


 

Exception in thread "main" java.lang.UnsupportedClassVersionError: a (Unsupported major.minor version 51.0)

    at java.lang.ClassLoader.defineClass0(Native Method)

    at java.lang.ClassLoader.defineClass(Unknown Source)

    at java.security.SecureClassLoader.defineClass(Unknown Source)

    at java.net.URLClassLoader.defineClass(Unknown Source)

    at java.net.URLClassLoader.access$100(Unknown Source)

    at java.net.URLClassLoader$1.run(Unknown Source)

    at java.security.AccessController.doPrivileged(Native Method)

    at java.net.URLClassLoader.findClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClass(Unknown Source)

    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

The Java version I have is 1.4.2_03. Can anyone tell me what I’m doing wrong here?

1 Answer

0 votes
by (19.7k points)

Change the PATH settings to a newer version of Java which is 7 and remove the 1.4.2 Path. After you save it, relaunch your command prompt to check the Java version --java version. 

After saving and applying "Environment Variables'' close and reopen the cmd line. In XP the path does not get reflected in already running programs.

Interested in Java? Check out this Java Certification by Intellipaat.

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...