How do I set dynamic JAVA_HOME paths for maven?
There is a maven.terminal.customEnv variable I can set with this object:
{
"environmentVariable": "JAVA_HOME",
"value" : "C:\\Java\\jdk-20.0.1"
}
but that is static. Maven will always use defined value.
I want to set multiple "JAVA_HOME" paths for maven so that the Visual Studio Code can run maven with the proper one based on the values in pom.xml.
EDIT: For an example, in Eclipse I can choose Run As --> Maven build ... and then choose Java that will be used to build the code in JRE section. It is still not an automatic process based on pom.xml but at least the build configuration is being saved in specific workspace. In another words, I can build 2 projects in parallel, one with e.g. Java 8 and one with Java 20. In VSCode I need to change JAVA_HOME for each different build because maven.terminal.customEnv is a global setting.
--show-version package flag can show which Java is being used to build a code.