Install Apache Maven on Fedora Linux 35

Apache Maven is an open-source tool that allows the building automation of your java projects. It can also be used for projects in C#, Ruby, etc. Its most popular usage would likely involve Java development! The maven project comes from the Apache Software Foundation, where they were previously part of the Jakarta Project before moving on their own clutches.

In the following tutorial, you will learn how to install Apache Maven on Fedora Linux 35.

Updating Fedora System

Before you begin, make sure your Fedora system is up-to-date using the following command.

sudo dnf upgrade --refresh -y

Option 1. Install Apache Maven – DNF Manager

Fedora features Apache Maven in its default repository, making the installation straightforward. Sometimes, this can be a few versions behind; however, even for Fedora with commonly new six-monthly releases featuring entire version upgrades, the version available is often stable.

Use the following command to begin the installation.

sudo dnf install maven

Example output:

Install Apache Maven on Fedora Linux 35

Type Y, then press the ENTER KEY to proceed.

For users that prefer using the latest version of Maven, if the Fedora repository version is out of date, look to the next section.

Option 2. Install Apache Maven – Manually

The second option is to download and install the latest version manually, which can be better suited for more experienced users.

Install Java

First, before you install Apache, you must install Java on Fedora using the following command.

sudo dnf install java-openjdk -y

Download & Setup

Next, use the wget command to download the archive. To find the latest version, visit here.



Next, extract the archive folder to the /opt/ directory.

sudo tar xzf apache-maven-3.8.4-bin.tar.gz -C /opt/

Now, navigate to the directory.

cd /opt/

Given that you have extracted the directory to the /opt/ location, you can either rename the folder or symlink it. Often, the symlink is the recommended method.

sudo ln -s apache-maven-3.8.4 maven

Install Apache Maven Environment

The environment variables need to be set, and this can be done by creating under the /etc/profile.d/ directory.

sudo nano /etc/profile.d/

Next, add the following to the file.

export M2_HOME=/opt/maven
export PATH=${M2_HOME}/bin:${PATH}

The last task is now to enable the environment with the following command.

source /etc/profile.d/

Confirm the installation by running the following command.

mvn -version

Example output:

Install Apache Maven on Fedora Linux 35

Comments and Conclusion

In the tutorial, you have learned two methods to install Apache Maven on Fedora Linux 35.

Overall, Maven is a great build tool that automates the whole process of building your project as per your requirements. It makes it easy for you to start your project in different environments without handling dependencies injection, builds or processing, etc., by adding new dependencies with some lines of commands only.


Like to get automatic updates? Follow us on one of our social media accounts!