YouTube Icon

Code Playground.

How to Install Apache Maven on CentOS 7


How to Install Apache Maven on CentOS 7

Apache Maven is a free and open-source venture the board and understanding instrument utilized fundamentally for Java ventures. Expert uses a Project Object Model (POM), which is basically a XML document containing data about the undertaking, design subtleties, the task's conditions, etc. 

In this instructional exercise we will show both of you various approaches to introduce Apache Maven on CentOS 7. 

The authority CentOS storehouses contain Maven bundles that can be introduced with the yum bundle director. This is the most straightforward approach to introduce Maven on CentOS. Nonetheless, the form remembered for the storehouses may fall behind the most recent variant of Maven. 

To introduce the most recent rendition of Maven, follow the means gave in the second piece of this article, where we will download Maven from their official site. 

Pick the establishment strategy that is generally fitting for your arrangement and climate. 


The client you are signing in as must have sudo advantages to have the option to introduce bundles. 

Installing Apache Maven on CentOS with Yum

Introducing Maven on CentOS 7 utilizing yum is a basic, clear cycle. 

Introduce Maven by composing the accompanying order in your terminal: 

sudo yum install maven

Check the establishment by composing the mvn - form order: 

mvn -version

The yield should look something like this: 

Apache Maven 3.0.5 (Red Hat 3.0.5-17)
Maven home: /usr/share/maven
Java version: 1.8.0_191, vendor: Oracle Corporation
Java home: /usr/lib/jvm/java-1.8.0-openjdk-
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.3.2.el7.x86_64", arch: "amd64", family: "unix"

That is it. Expert is currently introduced on your CentOS framework and you can begin utilizing it. 

Install the Latest Release of Apache Maven

The accompanying areas give a bit by bit directions about how to introduce the most recent Apache Maven form on CentOS 7. We'll be downloading the most recent arrival of Apache Maven from their official site. 

1. Install OpenJDK

Expert 3.3+ requires JDK 1.7 or above to be introduced. We'll introduce OpenJDK , which is the default Java advancement and runtime in CentOS 7. 

Introduce the OpenJDK bundle by composing: 

sudo yum install java-1.8.0-openjdk


Confirm that Java was effectively introduced by running the accompanying order: 

java -version

The yield should look something like this: 

openjdk version "1.8.0_191"
OpenJDK Runtime Environment (build 1.8.0_191-b12)
OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

2. Download Apache Maven

At the hour of composing this article, the most recent rendition of Apache Maven is 3.6.0. Prior to proceeding with the following stage, you should check the Maven download page to check whether a more current rendition is accessible. 

Start by downloading the Apache Maven in the/tmp index utilizing the accompanying wget order: 

wget -P /tmp

When the download is finished, extricate the document in the/pick catalog: 

sudo tar xf /tmp/apache-maven-3.6.0-bin.tar.gz -C /opt

To have more command over Maven forms and updates, we will make an emblematic connection expert that will highlight the Maven establishment catalog: 

sudo ln -s /opt/apache-maven-3.6.0 /opt/maven

To overhaul your Maven establishment, essentially unload the fresher form and change the symlink to highlight it. 

3. Setup environment variables

Next, we'll need to set up the climate factors. Open your content manager and make another record named within the/and so forth/profile.d/registry. 

sudo nano /etc/profile.d/

Glue the accompanying lines: 


export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Spare and close the record. This content will be sourced at shell startup. 

Make the content executable by running the accompanying chmod order: 

sudo chmod +x /etc/profile.d/

Burden the climate factors utilizing the source order: 

source /etc/profile.d/

4. Verify the installation

To confirm that Maven is introduced, utilize the mvn - adaptation order which will print the Maven variant: 

mvn -version

You should see something like the accompanying: 

Apache Maven 3.6.0 (97c98ec64a1fdfee7767ce5ffb20918da4f719f3; 2018-10-24T18:41:47Z)
Maven home: /opt/maven
Java version: 1.8.0_191, vendor: Oracle Corporation, runtime: /usr/lib/jvm/java-1.8.0-openjdk-
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "3.10.0-862.3.2.el7.x86_64", arch: "amd64", family: "unix"

That is it. The most recent adaptation of Maven is currently introduced on your CentOS framework. 


You have effectively introduced Apache Maven on your CentOS 7. You would now be able to visit the official Apache Maven Documentation page and figure out how to begin with Maven. 

On the off chance that you hit an issue or have criticism, leave a remark underneath.