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)
我根本不明白这一点; 谁能解释一下呢? 谢谢
使用较新版本的JDK编译代码并尝试在较旧版本的JVM上运行时,可能会发生此错误。 这是您自己编译的代码吗?您使用的是IDE(如Eclipse)吗? 尝试更新您的JRE 。
这意味着您的编译器生成的目标是比您尝试运行它的JVM更高的Java版本。
例如,为java 6编译并使用java 5运行。
解决方案1:升级jvm(类型java -version看看你有什么)
解决方案2:针对较低版本(例如,在eclipse java编译器设置中)
应该使用与编译时相同的java版本来定义JAVA_HOME。
它说你正在使用不同版本的java运行时的类文件。 你正在安装什么程序(我注意到你的堆栈跟踪中的installj)?
尝试升级Java运行时。
当我安装JRE
1.8并尝试在Eclipse Kepler
上运行Hello World
of GAE application
时,我收到此错误。 这是解决方案:
我从Eclipse Marketplace
安装Java 8 support for Kepler
。 然后我通过转到Eclipse
解决了我的问题 – >右键单击项目文件 – > Properties
– > Java Build Path
,我删除了JRE System Library 1.6
,单击Add Library
– > JRE System Library
– > Installed JRE's
。 然后我点击Search
,它自动找到版本1.8
,然后我回到上一个视图,选择1.8,现在一切正常!