0

I am using Windows 10, VS Code with the Java Development Kit from the VS Code site, Amazon Corretto 11.0.5_10 and have my java.home path set to the program's directory and it is showing as correct in the Java Development kit.

So far I have tried: - Reinstalling the JDK, no change - Using the OpenJDK 11, same issue

The error I am getting.

PS D:\projects\Learning Sandbox\Java> & 'C:\Users\lavic\.vscode\extensions\vscjava.vscode-java-debug-0.23.0\scripts\launcher.bat' 'C:\Program Files\Amazon Corretto\jdk11.0.5_10\bin\java' '--enable-preview' '-Dfile.encoding=UTF-8' '-cp' 'C:\Users\lavic\AppData\Roaming\Code\User\workspaceStorage\78403716f5d459852c5885ad9cb3cb98\redhat.java\jdt_ws\Java_67cee730\bin' 'HelloWorld'
Error: LinkageError occurred while loading main class HelloWorld
        java.lang.UnsupportedClassVersionError: HelloWorld (class file version 57.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
PS D:\projects\Learning Sandbox\Java> 

The code I am attempting to run.

public class HelloWorld {
    public static void main(String[] args) {
    }
}

Thanks for the help in advance!

Edit The answer was found here: https://stackoverflow.com/a/55455633/8534275

Lavick81
  • 13
  • 1
  • 6
  • Possible duplicate of [How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version](https://stackoverflow.com/questions/10382929/how-to-fix-java-lang-unsupportedclassversionerror-unsupported-major-minor-versi) – mypetlion Nov 26 '19 at 22:01
  • 1
    I'm sorry if this isn't helpful, but if you're a Java beginner I recommend you find a good Java tutorial and start with that. If you're using an IDE (Eclipse, Netbeans VS Code), usually it takes care of compiling and running your program for you from within the IDE, not the command line. If you're a Java beginner and want to start with the command line, then that long command you are executing is not the way: it should be something more like `javac Hello.java` followed by `java Hello`. That said, my real advice is to follow a good tutorial. – DavidS Nov 26 '19 at 22:08

1 Answers1

1

I found the answer here: https://stackoverflow.com/a/55455633/8534275

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

Note that I didn't have the JDK 8 already installed and so I skipped this step. I also already had JDK 11 from Amazon Corretto install and so skipped step 2 also.

Community
  • 1
  • 1
Lavick81
  • 13
  • 1
  • 6