The Lazy Dev

Do less. Develop more.  
« Back to blog

Use update-alternatives to upgrade maven installation on Ubuntu.

Screenshot9

Use debian update-alternatives to easily swith from different version of the same program you have installed on your machine. Or, more frequently, just to switch to a new version in a fast and clean way.
Let's make a simple example with maven. Ubuntu repositories have an old version and I want to use the new one with the same comfort of the packaged one. Here we go.

Let's download and unzip the new maven distribution in your $HOME/software/maven2.2.1 or wherever else you like.
Now, from a terminal:

# sudo update-alternatives --config mvn

you will see what you have installed and configured and what is the actual default version (the one with the *)

to install the new version:

# sudo update-alternatives --install /usr/bin/mvn mvn /home/ildella/software/apache-maven-2.2.1/bin/mvn 1

now again:

# sudo update-alternatives --config mvn

you will see another options, choose the right number and that's it! From now on, the "mvn" command will be binded to the 2.2.1 version of the program.
Here is the screenshot of my whole terminal session.

Comments (0)

Leave a comment...