iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > Python >java 运行报错has been compiled by a more recent version of the Java Runtime
  • 243
分享到

java 运行报错has been compiled by a more recent version of the Java Runtime

2024-04-02 19:04:59 243人浏览 安东尼

Python 官方文档:入门教程 => 点击学习

摘要

javaweb运行报错:has been compiled by a more recent version of the Java Runtime (class file vers

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内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: java 运行报错has been compiled by a more recent version of the Java Runtime

本文链接: https://www.lsjlt.com/news/122744.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作