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 this simply? Thanks

+6
source share
5 answers

This error can occur when compiling code with a newer version of the JDK and trying to run it in an older version of the JVM . Is this your own code that you compile and do you use an IDE (e.g. Eclipse)? Try updating the JRE .

+11
source

This means that your compiler was creating something designed for a higher version of Java than the JVM you are trying to run.

for example, compiled for java 6 and works with java 5.

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

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

+1
source

JAVA_HOME must be defined using a java version that is younger than the one you used to compile.

+1
source

They say that you are using the class file for another version of java runtime. What program are you installing (I notice installj on your stack)?

Try updating the Java runtime.

0
source

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

I installed Java 8 support for Kepler from the Eclipse Marketplace . Then I solved the problem by choosing Eclipse Right-click the project file -> Properties Java Build Path , I deleted the 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 the previous view, chose 1.8, and now everything works fine!

0
source

Source: https://habr.com/ru/post/888602/


All Articles