java 运行报错has been compiled by a more recent version of the Java Runtime
javaweb运行报错:has been compiled by a more recent version of the Java Runtime (class file version 55.0)
报错信息:
Exception in thread "main" java.lang.UnsupportedClassVersionError: pers/cyz/BookManage has been compiled by a more recent version of the Java Runtime (class file version 54.0), this version of the Java Runtime only recognizes class file versions up to 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
解决办法:
在项目的属性里设置jdk版本,方法是右击项目-->properties-->java compiler --> Enable project specific settings -->将compiler compliance level设置为1.8,也就是与jvm一致的版本

一般这样的错误都是因为当前的jre不能对程序进行编译,Tomcat的版本高于JDK的版本导致的,当前运行的jdk是1.8而我用的Tomcat版本是Tomcat 9所以就会出现这个问题。
解决方法:
要么降低Tomcat的版本号,要么用更高的版本的JRE。
这里我选择使用高版本的JRE:

重启服务器再次运行项目,问题解决。
eclipse运行Java代码出现原因很多,具体问题具体分析。
解决方案:
如果是web项目,不要在打开的文件上右击,要到项目路径上去右击”run as“,之后选择“server”。
如果是mian方法项目,需要找到带有main方法的类,之后打开这个类,之后“run as”,之后选择“java applet”即可。
到此这篇关于java 运行报错has been compiled by a more recent version of the Java Runtime的文章就介绍到这了,更多相关java has been compiled by a more recent version内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Java中new关键字和newInstance方法的区别分享
在初始化一个类,生成一个实例的时候,newInstance()方法和new关键字除了一个是方法一个是关键字外,最主要的区别是创建对象的方式不同2013-07-07
Java异常 Factory method''sqlSessionFactory''rew exception;este
这篇文章主要介绍了Java异常 Factory method ‘sqlSessionFactory‘ threw exception; nested exception is java.lang.NoSuchMethodError:,本文介绍了springboot 引入mybatis-plus后报错的解决方案,以下就是详细内容,需要的朋友可以参考下2021-07-07
Spring Boot整合Mybatis并完成CRUD操作的实现示例
这篇文章主要介绍了Spring Boot整合Mybatis并完成CRUD操作的实现示例,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2018-12-12


最新评论