Installation of Apache Maven on CentOS 8
Installation
Begin by updating CentOS.
Yum update
- Confirm the download with ‘
Y
‘. - Wait until the update is finished.
To install Maven 3.3+ on CentOS, ensure you have JDK 1.7 or above. As of the latest update, Maven 3.6.3 is the recommended version.
Yum install java-11-openjdk-devel
- Confirm the download with ‘
Y
‘. - Check if the installation succeeded with:
java -version
- Download the Maven files with:
wget https://mirror.novg.net/apache/maven/maven-3/3.6.3/binaries/apache-maven-3.6.3-bin.tar.gz
- Extract the files to
/opt
with:tar xf apache-maven-3.6.3-bin.tar.gz -C /opt
- Establish a symbolic link for easier Maven updates with the command: `ln -s /opt/apache-maven-3.6.3 /opt/maven
Configuration Configuration of Maven
- Create the file named
maven.sh
into/etc/profile.d/
with:nano /etc/profile.d/maven.sh
- Fill the file with the following code:
export JAVA_HOME=/usr/lib/jvm/jre-openjdk
export M2_HOME=/opt/maven
export MAVEN_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}
- Save and exit the file.
- Make the file executable:
chmod +x /etc/profile.d/maven.sh
- Load the file with:
source /etc/profile.d/maven.sh
Verify the correct installation of Maven by employing the following command: mvn -version
Maven is now installed onto your VPS.