大家好,又见面了,我是你们的朋友全栈君。
执行main项目时候报错:
Exception in thread “main” java.lang.UnsupportedClassVersionError: com/css/test/JDBindServiceImpl : 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.access100(URLClassLoader.java:71) at java.net.URLClassLoader1.run(URLClassLoader.java:361) at java.net.URLClassLoader1.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.LauncherAppClassLoader.loadClass(Launcher.java:308) at java.lang.ClassLoader.loadClass(ClassLoader.java:358) at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
截图如下:
原因:
在网上找了一圈,最后在stackoverflow找到了本质原因
代码语言:javascript复制You get this error because a Java 7 VM tries to load a class compiled for Java 8
Java 8 has the class file version 52.0 but a Java 7 VM can only load class files up to version 51.0
In your case the Java 7 VM is your gradle build and the class is com.android.build.gradle.AppPlugin
简单来说,就是java的编译环境版本太低,java 8 class file的版本是52,Java 7虚拟机只能支持到51。所以需要升级到java 8 vm才行。
解决方法:
邮件项目——设置Java开发环境——更新为8
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/131690.html原文链接:https://javaforall.cn