运行java程序的时候出现Exception in thread "main" java.lang.UnsupportedClassVersionError:
作者:互联网
- 1
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/test/inherited/InheritableSon : 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)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$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$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
查看是因为编译环境的改变造成的。
解决办法:
将项目的编译环境设置成当前的JDK版本即可
步骤:
1. 右键项目—>Properties—> java Compiler–>Compiler Compliance level
2. 选择自己安装的当前的JDK环境即可
标签:lang,Exception,java,URLClassLoader,ClassLoader,defineClass,net 来源: https://www.cnblogs.com/zhuyeshen/p/11436589.html