EN
Maven / mvn - change used java version
6
points
In this short article we would like to show how to change Java version used by Maven to other one.
Solution: change JAVA_HOME variable value to proper Java path. |
Practical example
The example shows how to change JAVA_HOME
system variable value under Windows 10.
1. Before change:
$ mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: C:\Program Files\apache-maven-3.6.2
Java version: 11.0.2, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk-11.0.2
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
2. Setting new JAVA_HOME
system variable value:
3. Terminal re-run or operating system restart.
4. After change:
$ mvn -v
Apache Maven 3.6.2 (40f52333136460af0dc0d7232c0dc0bcf0d9e117; 2019-08-27T17:06:16+02:00)
Maven home: C:\Program Files\apache-maven-3.6.2
Java version: 1.8.0_201, vendor: Oracle Corporation, runtime: C:\Program Files\Java\jdk1.8.0_201\jre
Default locale: en_US, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
Now Java 1.8 is used with mvn.