Exception in thread ;main; java.lang.UnsupportedClassVersionError

报错信息:

Exception in thread main java.lang.UnsupportedClassVersionError: com/shizongger/sort/SelectorSort : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access 100(URLClassLoader.java:71)atjava.net.URLClassLoader script type="math/tex" id="MathJax-Element-115"100(URLClassLoader.java:71) at java.net.URLClassLoader/script1.run(URLClassLoader.java:361)
at java.net.URLClassLoader 1.run(URLClassLoader.java:355)atjava.security.AccessController.doPrivileged(NativeMethod)atjava.net.URLClassLoader.findClass(URLClassLoader.java:354)atjava.lang.ClassLoader.loadClass(ClassLoader.java:425)atsun.misc.Launcher script type="math/tex" id="MathJax-Element-116"1.run(URLClassLoader.java:355) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:354) at java.lang.ClassLoader.loadClass(ClassLoader.java:425) at sun.misc.Launcher/scriptAppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)

一般是由于高版本编译低版本运行导致的,解决的思路第一步查看自己的Java编译版本和运行版本是否一致:

shizongger@shizongger:~$ javac -version
javac 1.7.0_79
java version "1.7.0_79"
Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

编译和运行版本相同,再来看看 是否是Eclipse编译版本导致。项目右键-Properties-Java Compalier-Jdk Compliance,将Jdk版本设置为1.7,点击OK-Apply。
自此问题解决。

最新回复(0)
/jishujMbkrQaBMvS5xD8venx_2FBP_2Fa34RVQRP7N91mZw_3D_3D8