类已由更新版本的 Java 环境编译
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47457105/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Class has been compiled by a more recent version of the Java Environment
提问by user5218071
While running selenium script, I am getting the following error message in Eclipse console:
在运行 selenium 脚本时,我在 Eclipse 控制台中收到以下错误消息:
Class has been compiled by a more recent version of the Java Environment (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0.
类已由更新版本的 Java 环境(类文件版本 53.0)编译,此版本的 Java 运行时仅识别最高 52.0 的类文件版本。
- Java Version:
8
- IDE:
Eclipse Oxygen
- Firefox Version:
46
- 爪哇版:
8
- IDE:
Eclipse Oxygen
- 火狐版:
46
采纳答案by Nithin
This is just a version mismatch. You have compiled your code using java version 9 and your current JRE is version 8. Try upgrading your JRE to 9.
这只是版本不匹配。您已经使用 Java 版本 9 编译了代码,并且您当前的 JRE 是版本 8。尝试将您的 JRE 升级到 9。
49 = Java 5
50 = Java 6
51 = Java 7
52 = Java 8
53 = Java 9
54 = Java 10
55 = Java 11
56 = Java 12
57 = Java 13
58 = Java 14
回答by Eugene
53
stands for java-9, so it means that whatever class you have has been compiled with javac-9
and you try to run it with jre-8
. Either re-compile that class with javac-8
or use the jre-9
53
代表 java-9,所以它意味着你已经编译了任何类,javac-9
并且你尝试使用jre-8
. 要么javac-8
使用 jre-9重新编译该类,要么使用 jre-9
回答by Eric D
IDE: Eclipse Oxygen.3
IDE:Eclipse Oxygen.3
To temporarily correct the problem do the following:
要暂时更正问题,请执行以下操作:
Project menu
> Properties
> Java Compiler
> Compiler compliance level
> 1.8
Project menu
> Properties
> Java Compiler
> Compiler compliance level
>1.8
A permanent fix likely involves installing JDK 9.
永久性修复可能涉及安装 JDK 9。
FYI 1.8 is what Java 8 is called.
仅供参考 1.8 就是 Java 8 的名称。
Side bar
侧边栏
I recently returned to Java after a foray into C# (a breath of fresh air) and installed Eclipse Oxygen onto a clean system that had never had Java installed on it before. This default everythingwith a brand new install of Eclipse Oxygen yet somehow or other Eclipse can't get its own parameters to match the jdk that's installed. This is the second project I created and the second time I ran into this headache. Time to go back to C#?
在尝试了 C#(呼吸新鲜空气)后,我最近回到了 Java,并将 Eclipse Oxygen 安装到了一个以前从未安装过 Java 的干净系统上。这种默认的一切都与一个全新的安装Eclipse氧但不知何故或其他Eclipse不能让自己的参数匹配的已安装了JDK。这是我创建的第二个项目,也是我第二次遇到这种头痛。是时候回到 C# 了吗?
Related Question
相关问题
has been compiled by a more recent version of the Java Runtime (class file version 53.0)
回答by ARVIND1994
Go to Project section, click on properties > then to Java compiler > check compiler compliance level is 1.8 , or there should be no yellow warning at bottom
转到“项目”部分,单击“属性”>“Java 编译器”>“检查编译器合规性级别为 1.8”,否则底部不应出现黄色警告
回答by Carlos Casallas
Refreshing gradle dependencies works for me: Right click over the project -> Gradle -> Refresh Gradle Project.
刷新 gradle 依赖项对我有用:右键单击项目 -> Gradle -> 刷新 Gradle 项目。
回答by Krishna Santosh Nidri
You can try this way
你可以试试这个方法
javac --release 8 yourClass.java