Peter
Peter

Reputation: 71

What is the reason for UnsupportedClassVersionError?

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

Upvotes: 7

Views: 8606

Answers (5)

Denis Kutlubaev
Denis Kutlubaev

Reputation: 16114

I was getting this error when I installed JRE 1.8 and tried to run Hello World of GAE application on Eclipse Kepler. This is solution:

I installed Java 8 support for Kepler from Eclipse Marketplace. Then I resolved my problem by going to Eclipse -> Right click on project file -> Properties -> Java Build Path, I removed JRE System Library 1.6, clicked Add Library -> JRE System Library -> Installed JRE's. Then I clicked Search, it automatically found version 1.8 and then I returned to previous view, selected 1.8 and now everything works fine!

Upvotes: 0

Raman
Raman

Reputation: 885

JAVA_HOME should be defined with the java version that younger ot the same that you used for compilation.

Upvotes: 1

cidermonkey
cidermonkey

Reputation: 306

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)

Upvotes: 1

DJ.
DJ.

Reputation: 6774

It is saying you are using class file for different version of java runtime. What program are you installing (I notice installj in your stacktrace)?

Try upgrading your Java runtime.

Upvotes: 0

keyboardP
keyboardP

Reputation: 69372

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.

Upvotes: 12

Related Questions