Saturday 9 August 2014

UnsupportedClassVersionError

Thrown when the Java Virtual Machine attempts to read a class file and determines that the major and minor version numbers in the file are not supported.

Usually if you try to run classes compiled with a higher version on a lower version JVM, then this error thrown.

class A{
 public static void main(String args[]){
 }
}

I compiled 'A.java'with javac version 1.7 and tried to run it on java version 1.8. JVM throws below error.

C:\>java A
Exception in thread "main" java.lang.UnsupportedClassVersionError: A : Unsupport
ed major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(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.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 sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)





                                                             Home

No comments:

Post a Comment