Reputation: 133
I've looked everywhere. I've tried following
And a host of other references that all say the same thing: Add "java.home" to your settings.json file, with the path to your jdk. And I have done just that.
I have tried adding java.home to both the User level and Workspace level of the settings.json file. However, when I go to build my project with "mvn clean install -Dmaven.test.skip=true", it is still pointing at a JRE, and subsequently fails.
Also, I found references to this so-called "Configure Java Runtime" wizard (hardly a wizard, since I can't change anything), that detects my different JDKs. However, I can't seem to select anything, or change the priority of things under the "Detected JDKs" section.
Yes, setting JAVA_HOME as an environment variable (Windows 10) to the appropriate path works. But I support many different projects that force me to swap between different JDK versions. It would nice to be able to store this information within the projects themselves, rather than having to remember when to swap the JAVA_HOME value manually every time.
Thanks in advance for the assistance.
Upvotes: 7
Views: 6837
Reputation: 374
This is how I do it. Add this to your vscode settings:
"maven.terminal.customEnv": [
{
"environmentVariable": "JAVA_HOME",
"value": "/path/to/jdk
}
]
Yes, this is adding a JAVA_HOME env variable, but only for maven terminals.
Of course, I assume you have installed the maven for java plugin: https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-maven
You can view a full configuration reference here:
https://github.com/Microsoft/vscode-maven
Upvotes: 6