1

When i am hitting f5 i get this text in debug window

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 shows

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)

Code that i am trying to compile

public class Hello {
    public static void main(String[] agrs)
    {
        System.out.println("Hello world!");
    }
}

PATH,JAVA_HOME and JRE_HOME are set properly. Debug add-on installed. I can compile and run the same code in InteliJ IDEA or using java (file), javac (file) and it will work fine but i don't know why it does not work on vscode.

7
  • What package are you using in VSCode to debug your java code? Commented Apr 4, 2019 at 21:10
  • Also you made a typo in your text. You said String[] agrs when you meant to type String[] args Commented Apr 4, 2019 at 21:11
  • Seems like a bug in the debugger extension. Very similar Q a few days ago: stackoverflow.com/q/55443351 (doesn't seem to be a dupe though, as the error messages are different) You could also try updating the extension. Commented Apr 4, 2019 at 21:14
  • @DylanRiley marketplace.visualstudio.com/… Commented Apr 4, 2019 at 21:15
  • @JornVernee Extension and VSCode is latest version Commented Apr 4, 2019 at 21:15

1 Answer 1

3

@JornVernee send link to other question, it helped Link to question

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.