Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the reason for UnsupportedClassVersionError?

Tags:

java

java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:676)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
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:317)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:280)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at com.exe4j.runtime.LauncherEngine.launch(Unknown Source)
at com.install4j.runtime.MacLauncher.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:592)
at apple.launcher.LaunchRunner.run(LaunchRunner.java:115)
at apple.launcher.LaunchRunner.callMain(LaunchRunner.java:50)
at apple.launcher.JavaApplicationLauncher.launch(JavaApplicationLauncher.java:52)

I don't understand this at all; can anyone explain it simply? Thanks

like image 995
Peter Avatar asked May 19 '11 23:05

Peter


2 Answers

This error can occur when you compile the code with a newer version of the JDK and try to run it on an older version of the JVM. Is this your own code you're compiling and are you using an IDE (like Eclipse)? Try updating your JRE.

like image 113
keyboardP Avatar answered Nov 14 '22 23:11

keyboardP


It means that your compiler was producing something targeted at a higher Java version than the JVM you are attempting to run it on.

eg compiled for java 6 and running with java 5.

Solution 1: upgrade the jvm (type java -version to see what you have)

Solution 2: target a lower version (in eclipse java compiler settings, for example)

like image 20
cidermonkey Avatar answered Nov 14 '22 23:11

cidermonkey