I am managing JAVA_HOME using jenv. I get the error 'The JAVA_HOME environment variable points to a missing folder'.
From the terminal:
loweedw$ echo $JAVA_HOME
/Users/loweedw/.jenv/versions/1.8
loweedw$ ls -l $JAVA_HOME
lrwxr-xr-x 1 loweedw Users 64 7 Aug 00:40 /Users/loweedw/.jenv/versions/1.8 -> /Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
I set java.home to the exact same value, and it seems to work fine.
Most likely this is the way code works. It seems it only picks up environment variables when it's launched from the terminal.
console.log(process.env)Same issue happens to me, I fix this by setting "java.home" in "USER SETTINGS"
{
"gitlens.advanced.messages": {
"suppressShowKeyBindingsNotice": true
},
"files.encoding": "iso88591",
"explorer.confirmDelete": false,
"editor.largeFileOptimizations": false,
"java.home": "/Library/Java/JavaVirtualMachines/jdk-11.0.3_7.jdk/Contents/Home",
}
For me I pointed to the version in jenv for java.home in settings.json. For my machine, it looked like:
"java.home": "/Users/blimmer/.jenv/versions/openjdk64-1.8.0.212
Would be nice if VS Code could pick which JDK to use based on the .java-version file of a given project who's using jenv to manage JDKs.
This PR https://github.com/redhat-developer/vscode-java/pull/1104 should resolve the issue.
In-case if you want a quick solution
Enabling export plugin for jenv worked for me
jenv enable-plugin export
Most helpful comment
For me I pointed to the version in jenv for
java.homeinsettings.json. For my machine, it looked like: