'Java on VSCode Extension Pack for Java can't detect jdk
I am trying to run java on vscode however the 'Extension Pack for Java' keeps asking me to redownload the jdk. I am able to run java on intellij and have been using that but since I use vscode for everything else I would like to get it to work on my main editor.
Here are the settings related to java
"java.help.firstView": "gettingStarted",
"java.home":"/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin/java",
"java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin/java",
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/Library/Java/JavaVirtualMachines/microsoft-17.jdk/Contents/Home/bin/java",
},
{
"name": "JavaSE-17",
"path": "/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home/bin/java",
},
{
"name": "JavaSE-17",
"path": "/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home/bin/java",
"default": true
},
],
Error The java.home variable defined in Visual Studio Code settings points to a missing or inaccessible folder (/Library/Java/JavaVirtualMachines/adoptopenjdk-17.jdk/Contents/Home)
any ideas?
All other languages I use work fine, it just seems to be java.
Solution 1:[1]
Assume you are using the latest Java extensions, here are some suggestions:
java.homehas been deprecated, please don't use it and usejava.jdt.ls.java.homeinstead- The latest Java extension already embeds a jre 17, you can find it in
$home/.vscode/extensions/redhat.java-1.x.0/jre. Ideally there is no need to specifyjava.jdt.ls.java.home, unless your platform is not covered. - If your platform is not covered, then you need to manually set
java.jdt.ls.java.home, which should point to the home path of your JDK installation. So please update it to/Library/Java/JavaVirtualMachines/amazon-corretto-17.jdk/Contents/Home. java.configuration.runtimesis used to map different JDK versions to their installation path. Please make sure each version only appear once in this setting.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sheng Chen |
