Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve VScode UnsupportedClassVersionError?

Problem

When i run my HelloWorld, it returns:

"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?

Screenshot

enter image description here

Code

public class HelloWorld{
    public static void main(String[] args) {
        System.out.println("123");
    }
}
like image 225
rui yang Avatar asked Mar 31 '19 17:03

rui yang


1 Answers

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

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

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

summary:
1. make sure uninstall jdk8 clean
2. install jdk11
3. add "vmArgs": "--enable-preview" in launch.json
4. F1, "Java: Clean ……" and "Java: Force ……"
5. run standalone file again

like image 162
mjuchi Avatar answered Sep 29 '22 06:09

mjuchi