Thursday, May 31, 2012

How to install Maven in Ubuntu 11.10

Installation of Maven in Ubuntu Linux is simple and straightforward.

First you need to download maven from Apache web-site.

Unpack it:
unzip apache-maven-3.0.4-bin.zip


I prefer to put all manually installed software to /opt but you can select /usr/local/bin or any other directory as well:
sudo mv apache-maven-3.0.4 /opt

Now let's create a symbolic link to this directory with a shorter name:
cd /opt
ln -s /opt/apache-maven-3.0.4/ maven

Now if things go wrong with this version we will be able to change it easily just by changing symbolic link.

The last thing we need to do is to specify where our maven executables are.
We need to add this line at the end of  ~/.bashrc:
export PATH=/opt/bin:${PATH}

or if you selected other directory:
export PATH=<path-to-maven-folder>/bin:${PATH} 

Now you need to close your shell and open it again, or do:
source ~/.bashrc

or just to execute the command you added to the end of your .bashrc in your shell.

Now you can check if your Maven works:
$ mvn --version
Apache Maven 3.0.4 (r1232337; 2012-01-17 08:44:56+0000)
Maven home: /opt/mavenJava version: 1.7.0_02, vendor: Oracle Corporation
Java home: /usr/lib/jvm/jdk1.7.0/jre
Default locale: en_GB, platform encoding: UTF-8
OS name: "linux", version: "3.0.0-20-generic", arch: "i386", family: "unix"

Everything seems to be OK.
That's all.
Good luck.

No comments:

Post a Comment