Spiga

Java Unsupported Class Version Error

Java Unsupported Class Version Error

Java Unsupported Class Version Error occurs when we try to compile the class which has a jar file attached in its classpath and that jar file has been compiled with higher version of java then the one with which  we are trying to compile the class.

This error comes on using different java versions for compilation and execution of java program. Therefore set the path of one java version and use it for compilation and execution.

java.lang.UnsupportedClassVersionError: XXXX (Unsupported major.minor version 49.0)

        at java.lang.ClassLoader.defineClass0(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:251)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:55)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:194)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:187)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:289)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:274)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:235)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:302)

 If you get the above errors, do the following:
       1) Check the jar file attached in the classpath.
       2) Use the higher version (or equal but not lesser) of java for compiling the class then used for creating  the jar.
      3) Set the path of one java version and use it for compilation and execution.

0 comments: