如何解决VScode UnsupportedClassVersionError? [英] How to solve VScode UnsupportedClassVersionError?

查看:45
本文介绍了如何解决VScode UnsupportedClassVersionError?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行HelloWorld时,它将返回:

When i run my HelloWorld, it returns:

"java.lang.UnsupportedClassVersionError:HelloWorld已编译通过Java Runtime的最新版本(类文件版本)52.65535),此版本的Java运行时只能识别52.0以下的类文件版本.

"java.lang.UnsupportedClassVersionError: HelloWorld has been compiled by a more recent version of the Java Runtime (class file version 52.65535), this version of the Java Runtime only recognizes class file versions up to 52.0 "

我该如何解决这个问题?

How do I solve this problem?

public class HelloWorld{
    public static void main(String[] args) {
        System.out.println("123");
    }
}

推荐答案

问题与Java Debugger扩展有关.我遇到了同样的问题,它已经记录在问题日志中: https://github.com/Microsoft/vscode-java-debug/issues/555

The issue is connected with Java Debugger extension. I had the same problem and it has been logged in issue log: https://github.com/Microsoft/vscode-java-debug/issues/555

问题仅适用于单个文件应用程序,例如HelloWorld.如果您运行的是Maven项目,那没关系.

Problem is only with single file applications like HelloWorld. It is ok if you run maven project.

梅德森克(Medsonk)的指令对我有用: https://github.com/Microsoft/vscode-java-debug/issues/555#issuecomment-478464496

Medsonk's instruction worked for me: https://github.com/Microsoft/vscode-java-debug/issues/555#issuecomment-478464496

摘要:
1.确保卸载jdk8 clean
2.安装jdk11
3.在launch.json中添加"vmArgs":-enable-preview"
4. F1,"Java:清洁……"和"Java:强制……"
5.再次运行独立文件

这篇关于如何解决VScode UnsupportedClassVersionError?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆