How to Install Apache Maven on Fedora Linux

Apache Maven is a robust build automation tool extensively utilized in Java-based projects for managing dependencies, building, and deploying applications. It offers a comprehensive suite of features that streamline the entire build process, simplifying Java application development. Maven is founded on the Project Object Model (POM), a configuration file outlining the project’s dependencies, build process, and distribution management.

Maven’s primary goal is to facilitate an effortless and predictable build process while delivering a uniform build system that multiple projects can leverage. It eases dependency management, as well as building and deploying applications. Maven employs a central repository to house all project dependencies, streamlining their management and mitigating version conflicts.

The build process of Maven is highly customizable, offering an extensive array of plugins to augment the build process functionality. Key plugins include the compiler plugin, surefire plugin, packaging plugin, and deploy plugin. The compiler plugin compiles source code, the surefire plugin executes unit tests, and the packaging plugin generates project artifacts, such as JAR or WAR files. The deploy plugin deploys project artifacts to a remote repository.

This guide illustrates how to install Apache Maven on Fedora Linux using the command-line terminal and Fedora’s default repository or by downloading and installing the latest version manually. The installation procedure is uncomplicated, consisting of a few straightforward steps that can be executed within minutes. Once installed, Maven enables you to build and manage your Java projects, automating the build process, handling dependencies, and seamlessly deploying your applications.

Update Fedora

It is recommended to perform a system package update and upgrade in the command line console before installing Apache Maven. This will ensure that all the necessary system packages are up-to-date and that any potential conflicts during the installation can be avoided.

sudo dnf upgrade --refresh

Method 1: Install Apache Maven with Fedora

Apache Maven can be easily installed on Fedora by utilizing the default repository provided by the operating system. Although the default version may sometimes lag behind the latest version of Maven, it is often stable, even on Fedora, with new six-monthly releases that feature entire version upgrades.

To install Apache Maven using the default Fedora repository, execute the following command in the command line console with root privileges:

sudo dnf install maven

This command will download and install the latest available version of Maven from the default Fedora repository.

After the installation is complete, you can verify the installation by checking the version of Apache Maven installed on your system. Type the following command in the Terminal:

mvn -version

If the installation is successful, the command will display the version of Apache Maven installed on your system.

Method 2: Install Apache Maven Manually

The second option is manually downloading and installing the latest version, which can be better suited for more experienced users. First, before you install Apache, you must install Java on Fedora using the following command.

sudo dnf install java-openjdk

To download the Apache Maven archive, you can use the wget command in the command line console. It is recommended to visit the official Apache Maven website to find the latest version before downloading.

Once you have identified the latest version of Maven, you can use the wget command followed by the download link to download the archive to your local machine.

For example, the guide will download Maven 3.9.0:


After downloading the Apache Maven archive, you can proceed with the installation process. This typically involves extracting the downloaded file and setting up the appropriate environment variables.

To extract the downloaded file, navigate to the directory where the file is located and execute the following command in the command line console:

tar xzf apache-maven-3.9.0-bin.tar.gz

This command will extract the archive’s contents to a new directory called “apache-maven-3.9.0”.

Next, you must set up the environment variables to enable using Maven from the command line console. This can be done by adding the following lines to the .bashrc file:

export M2_HOME=/path/to/maven
export PATH=$PATH:$M2_HOME/bin

Replace “/path/to/maven” with the path to the directory where you extracted the Apache Maven archive. For example:

export M2_HOME=/home/user/apache-maven-3.9.0
export PATH=$PATH:$M2_HOME/bin

Save the changes to the .bashrc file and execute the following command to apply the changes:

source ~/.bashrc

This will refresh the environment variables and make Maven available from the command line console.

To verify that Maven is installed and working correctly, execute the following command:

mvn -version

This command will display the installed version of Maven and its configuration details. If everything is set up correctly, you should see the version information displayed in the console.

Create a Test Apache Maven Project

To test if Apache Maven has been installed correctly on your Fedora Linux system, you can create and build a new Maven project using the command line console.

First, create a new directory for your project and navigate to it in the command line console. Then, use the following command to create a new Maven project:

mvn archetype:generate -DgroupId=com.example -DartifactId=my-project -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

This command will create a new Maven project with the group ID “com.example”, artifact ID “my-project,” and the “maven-archetype-quickstart” archetype. The “-DinteractiveMode=false” flag tells Maven not to prompt for any additional input during the project creation process.

Once the project has been created, navigate to the project directory and use the following command to build the project:

mvn package

This command will compile the project source code, run any tests, and create a JAR file in the “target” directory. If the build is successful, you should see output similar to the following in the console:

[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] Total time: X.XXX s
[INFO] ------------------------------------------------------------------------

Congratulations! You have successfully tested Apache Maven on your Fedora Linux system. You can now use Maven to manage dependencies, build, and easily deploy your Java applications.


In conclusion, installing Apache Maven on Fedora Linux is a straightforward process that involves a few simple steps. Following the installation guide, users can successfully set up Maven on their Fedora Linux systems and enjoy its powerful project management and comprehension tool capabilities. The process is made even easier thanks to the excellent documentation and resources provided by official sources.

Additional Resources and Links

Here is a list of additional resources and links to help you further explore Apache Maven and its features. Each link is accompanied by a brief description to provide you with an idea of what you can expect to find:

  • Official Apache Maven Website: The main source of information about Apache Maven, including its features, use cases, and benefits.
  • Apache Maven Documentation: Comprehensive documentation that covers various aspects of Maven, from getting started to more advanced topics.
  • Maven Central Repository: The central repository where Maven users can find and download plugins, dependencies, and other resources for their projects.
  • Apache Maven on GitHub: The official GitHub repository for Apache Maven, where you can access the source code, report issues, and contribute to the project.
  • Fedora Linux Official Website: Learn more about Fedora Linux, a popular open-source operating system that provides a great platform for software development and system administration tasks.

Share to...