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.

Kurisu
  • 41
  • 1
  • 1
  • 7
  • What package are you using in VSCode to debug your java code? – Dylan Riley Apr 04 '19 at 21:10
  • Also you made a typo in your text. You said `String[] agrs` when you meant to type `String[] args` – Dylan Riley Apr 04 '19 at 21:11
  • Seems like a bug in the debugger extension. Very similar Q a few days ago: https://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. – Jorn Vernee Apr 04 '19 at 21:14
  • @DylanRiley https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-debug – Kurisu Apr 04 '19 at 21:15
  • @JornVernee Extension and VSCode is latest version – Kurisu Apr 04 '19 at 21:15
  • Looks like the fix is in https://marketplace.visualstudio.com/items?itemName=redhat.java version 0.42.1 according to https://github.com/Microsoft/vscode-java-debug/issues/555#issuecomment-478825650 i.e. a dependency of the extension you linked. – Jorn Vernee Apr 04 '19 at 21:20
  • @JornVernee This fix didn't worked for me, but solution in link that you posted previously helped, thanks. – Kurisu Apr 04 '19 at 21:27

1 Answers1

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
Community
  • 1
  • 1
Kurisu
  • 41
  • 1
  • 1
  • 7