rui yang
rui yang

Reputation: 81

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");
    }
}

Upvotes: 8

Views: 11795

Answers (3)

Kutanagi
Kutanagi

Reputation: 1

  1. Uninstall your old Java version.
  2. Update JDK Development Kit https://www.oracle.com/java/technologies/downloads
  3. Install the new Java version.

It's work for me (I'm using Windows).

Upvotes: 0

beimuaihui
beimuaihui

Reputation: 25

My situation is version conflict between java and javac on Ubuntu;
just run this code:

sudo update-alternatives --config javac

Upvotes: -2

mjuchi
mjuchi

Reputation: 61

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

Upvotes: 6

Related Questions