The best way to force a specific JVM for MAVEN is to create a system wide file loaded by the mvn script.
This file is /etc/mavenrc
and it must declare a JAVA_HOME
environment variable pointing to your specific JVM.
Example:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64
If the file exists, it's loaded.
Here is an extract of the mvn
script in order to understand :
if [ -f /etc/mavenrc ] ; then . /etc/mavenrc fi if [ -f "$HOME/.mavenrc" ] ; then . "$HOME/.mavenrc" fi
Alternately, the same content can be written in ~/.mavenrc