How to Set Specific Java Version to Maven?
On My Machine I Have Two Java Versions Installed: (1.6 and 1.7 Installed Manually by Me). I Need Both of Them for Different Projects. but for Maven I Need 1.7...
On my machine I have two Java versions installed: (1.6 and 1.7 installed manually by me). I need both of them for different projects. But for Maven I need 1.7, but my Maven uses the 1.6 Java version.
How can I set Maven to use 1.7?
25 Answers
Maven uses the JAVA_HOME parameter to find which Java version it is supposed to run. I see from your comment that you can't change that in the configuration.
- You can set the
JAVA_HOMEparameter just before you start maven (and change it back afterwards if need be). - You could also go into your
mvn(non-windows)/mvn.bat/mvn.cmd(windows) and set your java version explicitly there.
Must Read
Edit:
A better solution is presented by the answer from Ondrej, which obviates remembering aliases.