Search code examples
javamavenjava-7java-6maven-toolchains-plugin

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, but my Maven uses the 1.6 Java version.

How can I set Maven to use 1.7?


Solution

  • 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_HOME parameter 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.