已由更新版本的 Java Runtime(类文件版本 57.0)编译

Has been compiled by a more recent version of the Java Runtime (class file version 57.0)(已由更新版本的 Java Runtime(类文件版本 57.0)编译)
本文介绍了已由更新版本的 Java Runtime(类文件版本 57.0)编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我使用 IntelliJ 遇到了这个问题.但是我的系统上新安装的所有东西都是最新版本.

...已由更新版本的 Java Runtime(类文件版本 57.0)编译,此版本的 Java Runtime 仅识别最高 52.0 的类文件版本

我已经设置好了:

PATH 为 C:Program FilesJavajdk-13JAVA_HOME 为:C:Program FilesJavajdk-13JRE_HOME 为:C:Program FilesJavajre1.8.0_221

我已经设置了路径,试图找到项目结构的变化

完整的错误信息:

H:87-JAVAHelloWorldsrc>java com.codewithmosh.Main错误:发生 JNI 错误,请检查您的安装并重试线程main"中的异常 java.lang.UnsupportedClassVersionError: com/codewithmosh/Main 已由 Java 运行时的更新版本(类文件版本 57.0)编译,此版本的 Java 运行时仅识别最高 52.0 的类文件版本在 java.lang.ClassLoader.defineClass1(本机方法)在 java.lang.ClassLoader.defineClass(未知来源)在 java.security.SecureClassLoader.defineClass(未知来源)在 java.net.URLClassLoader.defineClass(未知来源)在 java.net.URLClassLoader.access$100(未知来源)在 java.net.URLClassLoader$1.run(未知来源)在 java.net.URLClassLoader$1.run(未知来源)在 java.security.AccessController.doPrivileged(本机方法)在 java.net.URLClassLoader.findClass(未知来源)在 java.lang.ClassLoader.loadClass(未知来源)在 sun.misc.Launcher$AppClassLoader.loadClass(未知来源)在 java.lang.ClassLoader.loadClass(未知来源)在 sun.launcher.LauncherHelper.checkAndLoadMain(未知来源)

解决方案

您需要仔细检查 PATH 环境设置.C:Program FilesJavajdk-13 你目前有不正确的.请确保您在 PATH 列表的顶部有最新 JDK 版本的 bin 子目录.

java.exe 可执行文件位于 C:Program FilesJavajdk-13in 目录中,因此您需要在 路径.

使用

如果是这种情况,请从 PATH 中删除突出显示的部分,然后注销/登录或重新启动以使更改生效.您需要先以管理员身份重新启动才能编辑系统变量(请参阅系统变量列右上角的按钮).

I get this problem Using IntelliJ. But I have the newest version of everything newly installed on my system.

... has been compiled by a more recent version of the Java Runtime (class file version 57.0), this version of the Java Runtime only recognizes class file versions up to 52.0

I've set:

PATH as C:Program FilesJavajdk-13 JAVA_HOME as: C:Program FilesJavajdk-13 JRE_HOME as: C:Program FilesJavajre1.8.0_221

I've set the path, tried to find a change in the Project structure

COMPLETE ERROR MESSAGE:

H:87-JAVAHelloWorldsrc>java com.codewithmosh.Main
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/codewithmosh/Main has been compiled by a more recent version of the Java Runtime (class file version 57.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)

解决方案

You need to double check the PATH environment setting. C:Program FilesJavajdk-13 you currently have there is not correct. Please make sure you have the bin subdirectory for the latest JDK version at the top of the PATH list.

java.exe executable is in C:Program FilesJavajdk-13in directory, so that is what you need to have in PATH.

Use this tool to quickly verify or edit the environment variables on Windows. It allows to reorder PATH entries. It will also highlight invalid paths in red.

If you want your code to run on lower JDK versions as well, change the target bytecode version in the IDE. See this answer for the relevant screenshots.

See also this answer for the Java class file versions. What happens is that you build the code with Java 13 and 13 language level bytecode (target) and try to run it with Java 8 which is the first (default) Java version according to the PATH variable configuration.

The solution is to have Java 13 bin directory in PATH above or instead of Java 8. On Windows you may have C:Program Files (x86)Common FilesOracleJavajavapath added to PATH automatically which points to Java 8 now:

If it's the case, remove the highlighted part from PATH and then logout/login or reboot for the changes to have effect. You need to Restart as administrator first to be able to edit the System variables (see the button on the top right of the system variables column).

这篇关于已由更新版本的 Java Runtime(类文件版本 57.0)编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Show progress during FTP file upload in a java applet(在 Java 小程序中显示 FTP 文件上传期间的进度)
How to copy a file on the FTP server to a directory on the same server in Java?(java - 如何将FTP服务器上的文件复制到Java中同一服务器上的目录?)
FTP zip upload is corrupted sometimes(FTP zip 上传有时会损坏)
Enable logging in Apache Commons Net for FTP protocol(在 Apache Commons Net 中为 FTP 协议启用日志记录)
Checking file existence on FTP server(检查 FTP 服务器上的文件是否存在)
FtpClient storeFile always return False(FtpClient storeFile 总是返回 False)