Maven: How To Install Maven (Apache Maven) on CentOS 7(RHEL)

Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information. This tutorial will help you to install Apache Maven on your CentOS/RHEL.

Step 1 – Install Prerequisites (Install Java)

Java is the primary requirement of Apache Maven. So you need to install Java on your system. Make sure you have installed JDK, not JRE. For java installation visit how to install java on centos.

$ java -version

java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

Step 2 – Install Apache Maven

Download Apache maven from its official website or use following command to download Apache Maven 3.5.2 and extract downloaded archive.

$ cd /usr/local
$ wget

# Extract Apache maven archive
$ sudo tar xzf apache-maven-3.5.2-bin.tar.gz
$ sudo ln -s apache-maven-3.5.2 maven

Step 3 – Setup Environment Variables

Now set the environments variables by creating new file /etc/profile.d/ and load the environment variables in current shell using source command.

$ sudo vi /etc/profile.d/

# Add following content into above file
$ export M2_HOME=/usr/local/maven
$ export PATH=${M2_HOME}/bin:${PATH}

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

$ source /etc/profile.d/

Step 4 – Check installed Apache Maven Version

Use following command to check version of Maven.

$ mvn -version
Apache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-11-23T13:28:13+05:30)
Maven home: /usr/local/maven
Java version: 1.8.0_151, vendor: Oracle Corporation
Java home: /opt/jdk1.8.0_151/jre
Default locale: en_IN, platform encoding: UTF-8


Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.

More Posts - Website

Follow Me:
TwitterFacebookLinkedInGoogle Plus

Avinash Pawar

An automation enthusiast who presently working as DevOps Engineer.