Apache Maven is a 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. It was formerly part of the Jakarta Project. The installation of Apache Maven is a simple process. In this article we will install APache Maven on CentOS 8
Step 1: Install JAVA
We must install Java OpenJDK on CentOS 8 before installing maven so it can work properly.
Use following command to install Java
dnf install java-11-openjdk -y
Once the installation is complete. Verify Java installation using below command:
Step 2: Download and Install Apache Maven
We are going to install current latest version of Apache maven.
First install wget package
dnf install wget -y
Then go to /usr/local/ directory and use wget command to download maven.
Now Extract the compressed file and rename “apache-maven-3.6.3” directory with “maven” for ease of access.
tar -xvf apache-maven-3.6.3-bin.tar.gz
mv apache-maven-3.6.3 maven
Apache maven has been installed.
Step 3: Configure Environment for Apache Maven
In this step we will configure Apache Maven Environment so it can be used by all users on the server.
switch to /etc/profile directory and create maven.sh file using below commands.
Now paste below script content in this file
# Configuration of Apache Maven Environment Variables
Save changes to file and exit.
Next we have to make the script file executable and load the environment variables by using following commands
chmod +x /etc/profile.d/maven.sh
Verify Apache Maven installation.
If the installation successful you will see similar output.
Finally all of the configuration of Apache Maven has been completed.