Install apache maven 3 on linux

To install apache maven 3 on linux. Firstly, we will have to download the required maven version. It can be found at:

http://maven.apache.org/download.cgi

Once downloaded, open terminal and go to the download folder. Once there, extract the tar using the following

(Note: i have apache maven 3.0.5, so please replace apache-maven-3.0.5-bin with the version you have)

$ tar zxvf apache-maven-3.0.5-bin.tar.gz

Now, move the maven folder to /opt.

$ sudo mv apache-maven-3.0.5/ /opt/

Make sure you have java installed on your system, as we will need the path to java jdk. If you do not have java installed, you can install it from the following

https://saurab.com.np/index.php/2013/08/11/install-oracle-jdk-7-on-linux/

If you followed the above tutorial, your java home will be /usr/lib/jvm/jdk1.7.0_21. Replacing jdk1.7.0_21 with your version.

Once you get the location. Open .bashrc file present in /home/<user>/, using the following command

$ vim .bashrc

You can even use kate, gedit, nano or anything that is easy for you

Press “i” to enter value and add the following:

$ export M3_HOME=/opt/apache-maven-3.0.5
$ export M3=$M3_HOME/bin
$ export PATH=$M3:$PATH
$ export JAVA_HOME=/usr/lib/jvm/jdk1.7.0_21
$ export PATH=$JAVA_HOME/bin:$PATH

Once added, press the “Esc” key and type :wq to write to file and quit vim.

After the file is saved, we will have to load the .bashrc file. We can load it by using the following :

$ source .bashrc

Thus, maven is installed. To check the installation, you can use the following command :

$ mvn -version

It should give you the details about the installed maven

Reference :

  1. http://tutorialforlinux.com

Add a Comment

Your email address will not be published. Required fields are marked *