Wednesday, 13 November 2013

Install Maven latest release on Ubuntu

Disclamer :
I assume, you are using Ubuntu as Linux distribution. For information, my version is Ubuntu 13.04. And Java is already installed on your machine.
>java -version
java version "1.7.0_40"
Java(TM) SE Runtime Environment (build 1.7.0_40-b43)
Java HotSpot(TM) Server VM (build 24.0-b56, mixed mode)

Step 1 :
Run a complete Maven installation through the standard command line :
>sudo apt-get install maven

It installs Maven 3.0.4.



Test your installation by typing :
>mvn -version
Apache Maven 3.0.4
Maven home: /usr/share/maven
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-12-generic", arch: "i386", family: "unix"

Now you have Maven ready to run but this is not the latest release so you have to install it manually.

Step 2 :
Download Maven latest release from the Maven download page.

Unzip the tar.gz file in a directory. Using Nautilus, use the right button over the tar.gz file and choose "Extract here".

I will assume, you did it in /home/myuser/apache-maven/ directory for the rest of this tutorial.

Step 3 :
Add reference to this new maven version than the former one.

In your .profile (/home/myuser/.profile) add references to your new maven version.
M2_HOME="/home/myuser/apache-maven"
M2=$M2_HOME/bin

# set PATH so it includes Maven directory if it exists
if [ -d "$M2" ] ; then
    PATH="$M2:$PATH"
fi

You just have to reconnect yourself on your account or source your .profile.
> . ~/.profile

Step 4 :
Check your Maven installation. In my case, latest version of maven is maven 3.1.1.

>mvn -version
Apache Maven 3.1.1 (0728685237757ffbf44136acec0402957f723d9a; 2013-09-17 17:22:22+0200)
Maven home: /home/throdo/Programmation/Binaires/Maven/apache-maven-3.1.1
Java version: 1.7.0_40, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-7-oracle/jre
Default locale: fr_FR, platform encoding: UTF-8
OS name: "linux", version: "3.11.0-12-generic", arch: "i386", family: "unix"

Here it is !
You've got the latest version.

Hint :
If you want, you can add multiple version of maven, you just have to change the M2_HOME directory to choose an other version.

No comments :

Post a Comment