Reputation: 55
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.
Upvotes: 2
Views: 10326
Reputation: 23
JVM cant be found if it is installed in a directory owned by root (like /usr/lib/jvm), install the VM in a directory in your own home folder, that worked for me.
Upvotes: 0
Reputation: 1265
Assume you are using the latest Java extensions, here are some suggestions:
java.home
has been deprecated, please don't use it and use java.jdt.ls.java.home
instead$home/.vscode/extensions/redhat.java-1.x.0/jre
. Ideally there is no need to specify java.jdt.ls.java.home
, unless your platform is not covered.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.runtimes
is used to map different JDK versions to their installation path. Please make sure each version only appear once in this setting.Upvotes: 2