Vscode-java: JAVA_HOME with jenv on MacOS

Created on 28 Dec 2018  路  7Comments  路  Source: redhat-developer/vscode-java

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.

Environment
  • Operating System: MacOS
  • JDK version: jdk1.8.0_181
  • Visual Studio Code version: 1.30.1
  • Java extension version: 0.36.0
Steps To Reproduce
  1. Install jenv
  2. jenv enable-plugin export # To automatically set JAVA_HOME
  3. Install and load the Java plugin to VS Code
Additional Informations

Most helpful comment

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

All 7 comments

Most likely this is the way code works. It seems it only picks up environment variables when it's launched from the terminal.

  • open Dev tools (Command Palette >Toggle Developer Tools)
  • in the console, check what is the output of 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.

In-case if you want a quick solution

Enabling export plugin for jenv worked for me
jenv enable-plugin export

Was this page helpful?
0 / 5 - 0 ratings