6

Ubuntu 14.04

After installing and changing the version of mvn via `update-alternatives, the configuration remains unchanged.

Steps

  1. Install new version mvn

    sudo update-alternatives --install /usr/bin/mvn mvn /opt/maven/apache-maven-3.5.0/bin/mvn 100
    
  2. 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
    
  3. 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 
    
  4. 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
8
  • Add the output of type -a mvn, please. – muru Apr 19 '17 at 9:05
  • @muru I added it to the question – Joe Apr 19 '17 at 9:09
  • 1
    Your PATH probably has /opt/maven/apache-maven-3.3.9/bin in it. Remove it and try again. – muru Apr 19 '17 at 9:09
  • It seems to be this, but I commented with # in .profile but it is still apearing in env and set, I'll try rebooting – Joe Apr 19 '17 at 9:19
  • 1
    This question solved my problem :D Thanks for the very detailed question ;) – Menuka Ishan Dec 19 '18 at 11:53
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
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.