This is for the macOS:
By default, maven runs with the default JAVA_HOME configured in the system. If you want to set a different Java version temporarily for your maven - we need to change the JAVA_HOME in the mvn file.
mvn shell file
#!/bin/bash
JAVA_HOME="${JAVA_HOME:-$(/usr/libexec/java_home)}" exec "/usr/local/Cellar/maven/3.5.2/libexec/bin/mvn" "$@"
Changed mvn shell file this to:
#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home" exec "/usr/local/Cellar/maven/3.5.2/libexec/bin/mvn" "$@"
However, if you wish to set a particular java version to the project permanently - that needs to be configured in the pom.xml file
Refer here:
For example, to set for Java 1.8
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
Java 7:
<properties>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.source>1.7</maven.compiler.source>
</properties>
$ which mvn
/usr/local/bin/mvn
$ cat mvn
#!/bin/bash
JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home" exec "/usr/local/Cellar/maven/3.5.2/libexec/bin/mvn" "$@"
As you can see - mvn file is located in /usr/local/Cellar/maven/3.5.2/libexec/bin/
No comments:
Post a Comment