当我按下f5键时,我会在调试窗口中看到此文本
Error: LinkageError occurred while loading main class Hello
java.lang.UnsupportedClassVersionError: Hello (class file version 52.65535) was compiled with preview features that are unsupported. This version of the Java Runtime only recognizes preview features for class file version 56.65535
javac -version显示
javac 12
java -version
openjdk version "12" 2019-03-19
OpenJDK Runtime Environment AdoptOpenJDK (build 12+33)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 12+33, mixed mode, sharing)
我要编译的代码
public class Hello {
public static void main(String[] agrs)
{
System.out.println("Hello world!");
}
}
PATH,JAVA_HOME和JRE_HOME设置正确。 已安装调试插件。 我可以在InteliJ IDEA中编译并运行相同的代码,也可以使用java(文件),javac(文件)运行,但可以正常运行,但我不知道为什么它在vscode上不起作用。
答案 0 :(得分:2)
@JornVernee发送链接到其他问题,它有所帮助 Link to question
摘要:
- 确保卸载jdk8 clean
- 安装jdk11
- 在launch.json中添加“ vmArgs”:“-enable-preview”
- F1,“ Java:清洁……”和“ Java:强制……”
- 再次运行独立文件