最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
java运行报错has been compiled by a more recent version of the Java Runtime解决方法
时间:2022-06-29 00:54:21 编辑:袖梨 来源:一聚教程网
本篇文章小编给大家分享一下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”即可。
相关文章
- 四海兄弟故乡人物边缘模糊怎么办 人物边缘模糊解决方法 08-21
- 四海兄弟故乡神秘狐狸06怎么找 神秘狐狸06位置介绍 08-21
- 四海兄弟故乡神秘狐狸05怎么找 神秘狐狸05位置说明 08-21
- 诛仙2四海战歌奇遇怎么做 四海战歌东海奇遇收集 08-21
- 四海兄弟故乡神秘狐狸04怎么找 神秘狐狸04位置一览 08-21
- 四海兄弟故乡城市有多少 城市地点背景介绍 08-21