How To Install Apache Maven on CentOS/RHEL 7/6/5

Step 1 – Install Apache Maven

After verifying java version on you system. Download Apache maven from its official website or use following command to download Apache Maven 3.3.9.

$ cd /opt
$ wget http://www-eu.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz

Now extract downloaded archive using following command.

$ sudo tar xzf apache-maven-3.3.9-bin.tar.gz
$ sudo ln -s apache-maven-3.3.9 maven

Step 2 – Setup Environment Variables

As you have downloaded pre compiled Apache Maven files on your system. Now set the environments variables by creating new file /etc/profile.d/maven.sh.

$ sudo vi /etc/profile.d/maven.sh

and add following content.

export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Now load the environment variables in current shell using following command.

$ source /etc/profile.d/maven.sh

Step 4 – Check Version

Apache Maven has been successfully configured on your system. Use following command to check version of Maven.

$ mvn -version 

Leave a Reply

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