Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
981 views
in Technique[技术] by (71.8m points)

visual studio code - How to fix java.lang.UnsupportedClassVersionError: test (class file version 52.65535) was compiled with preview features that are unsupported?

I recieved this error when I trying to debug a java program with vscode:

java.lang.UnsupportedClassVersionError: 
test (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 55.65535

Here is launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "java",
            "name": "Debug (Launch) - Current File",
            "request": "launch",
            "mainClass": "${file}"
        },
        {
            "type": "java",
            "name": "Debug (Launch)-test",
            "request": "launch",
            "mainClass": "test"
        }
    ]
}

Here is the version of java:

java --version:
openjdk 11.0.2 2019-01-15
OpenJDK Runtime Environment (build 11.0.2+9-Ubuntu-3ubuntu118.04.2)
OpenJDK 64-Bit Server VM (build 11.0.2+9-Ubuntu-3ubuntu118.04.2, mixed mode, sharing)

javac --version:
javac 11.0.2

This program can run on ubuntu original terminal, but throws error in vscode.

it would be greatful if you can help me out.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In launch.json file, add "vmArgs": "--enable-preview" to your debug configuration.

{
   ...
   "vmArgs": "--enable-preview"
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...