Atlantic.Net Blog

How to Install Apache Maven on Rocky Linux 8

Hitesh Jethva
by Atlantic.Net (345 posts) under Dedicated Server Hosting, Tutorials
0 Comments

Apache Maven is a free, open-source, and extremely popular build management tool for Java projects. It is based on the Project Object Model and contains XML files to define configuration details, project dependencies, and other data. It is designed to help Java developers build projects by proficiently documenting and reporting important project-related information.

Features

  • All configuration is managed from a single XML file.
  • Easy to test and deploy.
  • Easy to manage upgrades.
  • Occupies less space than other project management tools.
  • Reduces multiple dependencies and eliminates duplicates.

In this post, we will show you how to install Apache Maven on Rocky Linux 8.

Prerequisites

  • A server running Rocky Linux 8 on the Atlantic.Net Cloud Platform
  • A root password is configured on your server

Step 1 – Create Atlantic.Net Cloud Server

First, log in to your Atlantic.Net Cloud Server. Create a new server, choosing Rocky Linux as the operating system with at least 2GB RAM. Connect to your Cloud Server via SSH and log in using the credentials highlighted at the top of the page.

Once you are logged in to your server, run the following command to update your base system with the latest available packages.

dnf update -y

Step 2 – Install Maven via AppStream Repository

By default, the Maven package is included in the Rocky Linux AppStream repository. You can check it using the following command:

dnf info maven

You should get the following output:

Name         : maven
Epoch        : 1
Version      : 3.5.4
Release      : 5.module+el8.3.0+133+b8b54b58
Architecture : noarch
Size         : 26 k
Source       : maven-3.5.4-5.module+el8.3.0+133+b8b54b58.src.rpm
Repository   : appstream
Summary      : Java project management and project comprehension tool
URL          : http://maven.apache.org/
License      : ASL 2.0 and MIT
Description  : Maven is a software project management and comprehension tool. Based on the
             : concept of a project object model (POM), Maven can manage a project's build,
             : reporting and documentation from a central piece of information.

Now, install the Apache Maven using the following command:

dnf install maven -y

After the installation, verify the Maven version using the following command:

mvn --version

You should get the following output:

Apache Maven 3.5.4 (Red Hat 3.5.4-5)
Maven home: /usr/share/maven
Java version: 11.0.12, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64
Default locale: en_US, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-305.10.2.el8_4.x86_64", arch: "amd64", family: "unix"

Step 3 – Install Maven From Source

If you want to install the latest version of Maven then you can install it from the Maven source. First, install the Java package with the following command:

dnf install java-11-openjdk -y

Once Java is installed, verify the Java version using the following command:

java --version

Sample output:

openjdk 11.0.12 2021-07-20 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.12+7-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.12+7-LTS, mixed mode, sharing)

Next, download the latest version of Maven from their official website:

wget https://downloads.apache.org/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz

Next, create a directory for Apache Maven with the following command:

mkdir /usr/local/maven

Next, extract the downloaded file to the Maven directory with the following command:

tar xzf apache-maven-3.8.1-bin.tar.gz -C /usr/local/maven/ --strip-components=1

Next, you will need to add the Maven binary location to the system path. You can add it with the following command:

echo export 'PATH=$PATH:/usr/local/maven/bin/' > /etc/profile.d/maven.sh
echo 'export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64' >> /etc/profile.d/maven.sh

Next, set proper permissions to the maven.sh file with the following command:

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

Next, activate the Maven system path with the following command:

source /etc/profile.d/maven.sh

Next, verify the Maven version using the following command:

mvn --version

You should get the following output:

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d)
Maven home: /usr/local/maven
Java version: 11.0.12, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-11-openjdk-11.0.12.0.7-0.el8_4.x86_64
Default locale: en_IN, platform encoding: UTF-8
OS name: "linux", version: "4.18.0-305.7.1.el8_4.x86_64", arch: "amd64", family: "unix"

Conclusion

In the above guide, we explained how to install Apache Maven on RockyLinux 8 using two methods. You can now use Apache Maven to manage your Java project – try it on dedicated server hosting from Atlantic.Net!

Get A Free To Use Cloud VPS

Free Tier Includes:
G3.2GB Cloud VPS Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


Looking for a Hosting Solution?

We Provide Cloud, Dedicated, & Colocation.

  • Seven Global Data Center Locations.
  • Flexible Private, Public, & Hybrid Hosting.
  • 24x7x365 Security, Support, & Monitoring.
Contact Us Now! Med Tech Award FTC
SOC Audit HIPAA Audit HITECH Audit

Recent Posts

How to Install Python 3.10 on Rocky Linux 8
How to Install TaskBoard on Rocky Linux 8
How to Set Up Pritunl VPN Server on Rocky Linux 8
How to Install Teampass Password Manager on Rocky Linux 8
How to Install and Configure RabbitMQ Server on Rocky Linux 8

Get started with 12 months of free cloud VPS hosting

Free Tier includes:
G3.2GB Cloud VPS Server Free to Use for One Year
50 GB of Block Storage Free to Use for One Year
50 GB of Snapshots Free to Use for One Year


New York, NY

100 Delawanna Ave, Suite 1

Clifton, NJ 07014

United States

San Francisco, CA

2820 Northwestern Pkwy,

Santa Clara, CA 95051

United States

Dallas, TX

2323 Bryan Street,

Dallas, Texas 75201

United States

Ashburn, VA

1807 Michael Faraday Ct,

Reston, VA 20190

United States

Orlando, FL

440 W Kennedy Blvd, Suite 3

Orlando, FL 32810

United States

Toronto, Canada

20 Pullman Ct, Scarborough,

Ontario M1X 1E4

Canada

London, UK

14 Liverpool Road, Slough,

Berkshire SL1 4QZ

United Kingdom

Resources