How to install Apache Maven on CentOS 8

How To Install Apache Maven On CentOS 8

On this article we will discuss how to install Apache Maven version 3.6.3 on Linux CentOS 8 operating system.


Apache Maven is a software project management and build automation tool used primarily for Java projects. Maven can also be used to build and manage projects written in C#, Ruby, Scala, and other languages. The Maven project is hosted by the Apache Software Foundation, where it was formerly part of the Jakarta Project. On this article, we will learn how to install the last version of Apache Maven is 3.6.3 released on 25 November 2019.

The Apache Maven installation steps will be described on several steps as mentioned below :

  • Prerequisite
  • Apache Maven Installation
    • Download source & extract files
    • Setting environment variables
  • Verifying Apache Maven Installation


System Requirements

As stated on Apache Maven official website, if the Apache Maven has several system requirements as follow :

  • Java Development Kit (JDK) Maven 3.3+ require JDK 1.7 or above to execute – they still allow you to build against 1.3 and other JDK versions by Using Toolchains
  • Memory No minimum requirement
  • Disk Approximately 10MB is required for the Maven installation itself. In addition to that, additional disk space will be used for your local Maven repository. The size of your local repository will vary depending on usage but expect at least 500MB.
  • Operating System No minimum requirement. Start up scripts are included as shell scripts and Windows batch files.

Another requirement is a root account or user with sudo privilege.

If we have no Java installed on our system, just install it first. The Java installation on CentOS 8 has discussed on How To Install Java (OpenJDK 11) on CentOS 8 article. first, we verify our Java version installed on our system, for this purpose we will submit command line below :

[ramans@otodiginet ~]$ java -version
openjdk version "" 2020-11-04 LTS
OpenJDK Runtime Environment 18.9 (build
OpenJDK 64-Bit Server VM 18.9 (build, mixed mode, sharing)
Checking Java version on CentOS 8

Apache Maven Installation

Download And Extract Apache Maven Source

On this section we will download the latest stable of Apache Mavent by using wget command line as shown below. wget The package file will be stored on /home/ramans directory ad move it to the /opt/maven directory.

[ramans@otodiginet ~]$ wget
 --2021-01-21 15:00:09--
 Resolving (…, 2a01:4f8:10a:201a::2
 Connecting to (||:443… connected.
 HTTP request sent, awaiting response… 200 OK
 Length: 9506321 (9.1M) [application/x-gzip]
 Saving to: ‘apache-maven-3.6.3-bin.tar.gz’
 apache-maven-3.6.3-bin.tar.gz 100%[==============================================>]   9.07M   856KB/s    in 14s     
 2021-01-21 15:00:25 (664 KB/s) - ‘apache-maven-3.6.3-bin.tar.gz’ saved [9506321/9506321]
Download Apache Maven source
Download Apache Maven source

After downloading was completed done, then we extract the file by using command line : tar -zxvf apache-maven-3.6.3-bin.tar.gz.

[ramans@otodiginet ~]$ tar -zxvf apache-maven-3.6.3-bin.tar.gz
Extract Apache Maven Source
Extract Apache Maven Source

Move all extrated files to the /opt/maven directory.

[ramans@otodiginet ~]$ sudo mkdir /opt/maven
[sudo] password for ramans:
[ramans@otodiginet ~]$ sudo mv apache-maven-3.6.3 /opt/maven

Setup Environment Variables

The next step is creating the environment variables. To do so, open text editor and create a new file named in the /etc/profile.d/ directory and put the content as below. (There will be vary for the Maven source file directory)

sudo vi /etc/profile.d/

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

Then we have to make the file and load the environment variables in current shell.

[ramans@otodiginet ~]$ sudo su -
Last login: Sun Dec 27 02:19:27 PST 2020 on pts/0
[root@otodiginet ~]# chmod +x /etc/profile.d/
[root@otodiginet ~]# source /etc/profile.d/
Make Apache Maven file
Make Apache Maven file

Verify Maven Installation

This is the last step on installing Apache Maven on CentOS 8. At this step we will verify Apache Maven installation by querying Maven version, by submitting command line below.

[root@otodiginet ~]# mvn -version
 Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
 Maven home: /opt/maven
 Java version:, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-
 Default locale: en_US, platform encoding: UTF-8
 OS name: "linux", version: "4.18.0-193.el8.x86_64", arch: "amd64", family: "unix"
Mavent Version
Mavent Version


The Apache Maven version 3.6.3 installation on CentOS 8 has been completed done sucessfuly. For the next step of using Apache Maven can be found on Apache Maven official web page.

Share this article via :

Leave a Reply

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