(类文件版本 53.0),Java 运行时版本高达 52.0 Visual Studio 代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/47102120/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 02:33:29  来源:igfitidea点击:

(class file version 53.0), Java Runtime versions up to 52.0 Visual studio code

javavisual-studio-code

提问by Dave Jones

I'm trying to use visual studio code for Java.

我正在尝试将 Visual Studio 代码用于 Java。

Have installed the extensions for Java, and have a 1.8 JDK installed with environment variable pointing to the install.

已经安装了 Java 扩展,并安装了 1.8 JDK,环境变量指向安装。

When starting debugger with a simple hello world program, I get the following:

使用简单的 hello world 程序启动调试器时,我得到以下信息:

java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) ...... ...... at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

java.lang.UnsupportedClassVersionError: HelloWorld 已由更新版本的 Java Runtime(类文件版本 53.0)编译,此版本的 Java Runtime 仅识别 java.lang.ClassLoader.defineClass1(Native Method) ...... ...... 在 sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495)

Any help with getting Java debugging in Visual Studio code appreciated.

任何在 Visual Studio 代码中进行 Java 调试的帮助表示赞赏。

回答by Roeland Van Heddegem

You are probably compiling (or using dependencies compiled) with java 9, but still using JDK 8.0

您可能正在使用 Java 9 编译(或使用编译的依赖项),但仍在使用 JDK 8.0

Install java 9 and change your OS environment settings to point to the new JDK. This should solve your problem.

安装 java 9 并更改您的操作系统环境设置以指向新的 JDK。这应该可以解决您的问题。