0% found this document useful (0 votes)
954 views

Installation of Apache Maven On Amazon Linux 2023

The document provides instructions for installing Apache Maven on an Amazon Linux 2023 system. It involves installing Java JDK 17, downloading and extracting the Maven binary package, creating a symbolic link for the Maven folder, adding the Maven bin directory to the system PATH, and verifying the Maven installation by checking the version. Key Maven configuration files and locations are also outlined.

Uploaded by

SIS Technologies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
954 views

Installation of Apache Maven On Amazon Linux 2023

The document provides instructions for installing Apache Maven on an Amazon Linux 2023 system. It involves installing Java JDK 17, downloading and extracting the Maven binary package, creating a symbolic link for the Maven folder, adding the Maven bin directory to the system PATH, and verifying the Maven installation by checking the version. Key Maven configuration files and locations are also outlined.

Uploaded by

SIS Technologies
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Finishline Maven Installation lab September 27, 2023

Installation of Apache Maven on Amazon Linux 2023


Apache maven is one of the best open-source java build tools. It is primarily used by
developers working on java projects and devops engineers working on CI/CD pipelines. A
developer primarily deals with the development aspects using maven while devops engineers
deal with setting up a Continuous Integration pipeline using maven.

Let’s get started with the maven setup.

Part1: Install Latest JDK

The basic prerequisite for Maven is Java JDK because Maven is a build tool and it requires all
the build and compiles related java tools.

In the lab we’re going install JDK 17 by running the command below.

sudo yum install java-17-amazon-corretto-devel –y

Verify Java JDK installation using the following command.

java –version

Part2: Install Maven 3.9.4 from Maven Repo

Step 1: Go to Maven Downlaods and get the download link of the latest package.
wget https://dlcdn.apache.org/maven/maven-3/3.9.4/binaries/apache-maven-3.9.4-bin.tar.gz

By Joseph Dong
Finishline Maven Installation lab September 27, 2023
Step 2: Untar the mvn package to the /opt folder.
sudo tar xvf apache-maven-3.9.4-bin.tar.gz -C /opt

Step 3: Create a symbolic link to the maven folder. This way, when you have a new version of
maven, you just have to update the symbolic link and the path variables remain the same.

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

Part 3: Add Maven Folder To System PATH


To access the mvn command systemwide, you need to either set the M2_HOME environment
variable or add /opt/maven to the system PATH.

We will do both by adding them to the profile.d folder. So that every time the shell starts, it
gets sourced and the mvn command will be available system-wide.

Step 1: Create a script file named maven.sh in the profile.d folder.


sudo vi /etc/profile.d/maven.sh

Step 2: Add the following to the script and save the file.
export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

Step 3: Add execute permission to the maven.sh script.


sudo chmod +x /etc/profile.d/maven.sh

Step 4: Source the script for changes to take immediate effect.


source /etc/profile.d/maven.sh

Step 5: Verify maven installation


mvn -version

By Joseph Dong
Finishline Maven Installation lab September 27, 2023

For Understanding purposes only

Maven Important Configurations


Following are the important maven configurations you should know.

Configuration Location Details


M2_HOME environment The location is the corresponding
variable maven installation directory in
the system.
.m2 local repository $HOME/.m2 When you run maven
commands, all the remote
repositories get cached locally
in the .m2 folder.
settings.xml (Global) $M2_HOME/conf/settings.xml This file contains all the maven
configurations that are
common for all the projects.
settings.xml (User Specific) $HOME/.m2/settings.xml

By Joseph Dong

You might also like