Can not change update-alternatives mvn
Ubuntu 14.04
After installing and changing the version of mvn
via `update-alternatives, the configuration remains unchanged.
Steps
-
Install new version mvn
sudo update-alternatives --install /usr/bin/mvn mvn /opt/maven/apache-maven-3.5.0/bin/mvn 100
-
Check alternatives
$ sudo update-alternatives --config mvn There are 2 choices for the alternative mvn (providing /usr/bin/mvn). Selection Path Priority Status ------------------------------------------------------------ * 0 /opt/maven/apache-maven-3.3.9/bin/mvn 100 auto mode 1 /opt/maven/apache-maven-3.3.9/bin/mvn 100 manual mode 2 /opt/maven/apache-maven-3.5.0/bin/mvn 10 manual mode Press enter to keep the current choice[*], or type selection number: 2 update-alternatives: using /opt/maven/apache-maven-3.5.0/bin/mvn to provide /usr/bin/mvn (mvn) in manual mode
-
Change alternative to new one
$ sudo update-alternatives --config mvn There are 2 choices for the alternative mvn (providing /usr/bin/mvn). Selection Path Priority Status ------------------------------------------------------------ 0 /opt/maven/apache-maven-3.3.9/bin/mvn 100 auto mode 1 /opt/maven/apache-maven-3.3.9/bin/mvn 100 manual mode * 2 /opt/maven/apache-maven-3.5.0/bin/mvn 10 manual mode Press enter to keep the current choice[*], or type selection number: 2
-
Check mvn version
$ mvn --version Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00) Maven home: /opt/maven/apache-maven-3.3.9 Java version: 1.8.0_111, vendor: Oracle Corporation Java home: /opt/java/jdk1.8.0_111/jre Default locale: ca_ES, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-116-generic", arch: "amd64", family: "unix"
type
command output:
$ type -a mvn
mvn is /opt/maven/apache-maven-3.3.9/bin/mvn
mvn is /usr/bin/mvn
Solution 1:
I had modified the ~/.profile
PATH
variable, so the only thing I had to do is to comment out the line and log in again.
.profile
...
#export PATH=/opt/maven/apache-maven-3.3.9/bin:$PATH
...