Invalid runtime for JavaSE-11: The path points to a missing or inaccessible folder

Viewed 3064

My VSCode is no longer recognizing the paths of the java runtime. I was using them normally and now it doesn't work on the same projects anymore. Here are the error messages and my settings. The paths to the runtimes are correct.

Environment:

  • Operating System: Linux Mint 20 Cinnamon
  • JDK version: Openjdk version "11.0.8" 2020-07-14
  • Visual Studio Code version: v1.49.2
  • Java extension version: v0.68.0

Error:

Java Error Message

  • settings.json:
    "java.home": "/usr/lib/jvm/java-11-openjdk-amd64",
    "java.configuration.runtimes": [
    
      {
        "name": "JavaSE-1.8",
        "path": "/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java",
      },
      {
        "name": "JavaSE-11",
        "path": "/usr/lib/jvm/java-11-openjdk-amd64/bin/java",
        "default": true
      },
      {
        "name": "JavaSE-14",
        "path": "/usr/lib/jvm/java-14-openjdk-amd64/bin/java",
      },
    ],
2 Answers

The “path” parameter should be set to the location of the Java runtime directory, not to the java executable file. Take “/bin/java” off the end.

I had to add /Contents/Home at the end of my path:

before: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk

after: /Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home

on OS X 11.1 and VS Code 1.52.1.

Related