Home / How To / How to install Apache Maven on CentOS 8

How to install Apache Maven on CentOS 8

Apache Maven is a software management tool based on the POM (Project, Object, Model) concept. Maven is a building automation tool primarily used for Java-based projects, but can also be used to build and manage projects written in C #, Ruby, Scala and other languages. It describes not only how software is built but also its dependencies.

In this tutorial we will show you step by step how to install and configure Apache Maven on a CentOS 8 system.


What we will do:

  1. Install Java OpenJDK on CentOS 8
  2. Download Apache Maven binary file
  3. Configure Apache Maven environment
  4. Test

Step 1 – Install Java OpenJDK on CentOS 8

First, we & # 39; will install Java OpenJDK on CentOS 8 from the AppStream repository. There are many OpenJDK versions provided by the AppStream repository, and we will use Java OpenJDK LTS version 1


You use the following command to get all available OpenJDK versions on AppStream.

  dnf search openjdk 
dnf info java-11-openjdk

Now install Java OpenJDK 11 with the dnf command below.

  sudo dnf install java-11-openjdk 

When installation is complete, check the Java version. [19659012] java version

And you get the result as below.

 Check the Java version

As a result, Java OpenJDK 11 has been installed on CentOS 8 Server.

Step 2 – Download Apache Maven binary file

In this tutorial we will install the latest stable version Apache Maven 3.6.2 by downloading its binary file.

Go to & # 39; / usr / local / src & # 39; directory and download the Apache Maven binary with the wget command.

  cd / usr / local / src 
wget https: // www -eu.apache.org/dist/maven/maven-3/3.6.2/binaries/apache-maven-3.6.2-bin. tar.gzebrit19659013achteExtract the compressed file and move the Apache maven directory to & # 39; / usr / local & # 39; as a & # 39; stomach & # 39; directory.

  tar -xf apache-maven-3.6.2-bin.tar.gz 
etc. apache-maven-3.6.2 / usr / local / maven / [19659013] Now Apache Maven has been installed in directory & # 39 ; / usr / local / maven & # 39 ;.

 Download Apache Maven

Step 3 - Configure Apache Maven Environment

In this step we will set the environment variable for Apache Maven. We will configure the Apache Maven environment variable directory through the & # 39; /etc/profile.d' directory, and it will allow the Apache Maven to be used by all users in the system.

Go to the & # 39; / etc /profile.d & # 39; directory and create the script & # 39; maven.sh & # 39; with the vim editor.

  cd /etc/profile.d/strong19459014vardvim maven.sh 

Paste the following script.

  # Apache Maven environment variables 
# MAVEN_HOME for Maven 1 - M2_HOME for Maven 2
export M2_HOME = / usr / local / maven
export PATH = $ {M2_HOME} / bin: $ {PATH} [19659013] Save and close.

Then the script does & # 39; maven.sh & # 39; executable and loads it to the system with the source command.

  chmod + x /etc/profile.d/maven.shebrit19459014??source/etc/profile.d/maven.shebrit19659013??Now the configuration of the Apache Maven environment variable has been completed. And as a result, the Apache Maven command is available to all users on the system. 

 Configure Maven environment

Step 4 - Test

To verify our Apache Maven installation, you can run the maven command below.

  mvn --version 

And you should get a result similar to the following:

 Test Maven

As a result, the installation of Apache Maven 3.6 has been completed. It runs under Linux CentOS 8 64bit, with Java OpenJDK 11 installed, and the Maven Home directory is & # 39; / usr / local / maven & # 39 ;. Chapter19659045 ?? Reference Chapter19659046]

Source link