How to Install Apache Maven on Fedora 39, 38 Linux

This guide will delve into the process of installing Apache Maven on Fedora Linux, presenting two distinct methods: the highly recommended Fedora app stream approach and an alternative manual installation via the Apache Maven tarball.

Apache Maven stands out as a pivotal tool in modern software development, particularly for Java projects. Its design philosophy centers around simplifying project management and enhancing build automation.

Let’s highlight some of its key features:

  • Effortless Project Setup: Maven streamlines the initiation of new projects or modules, adhering to best practices and ensuring rapid setup.
  • Consistency Across Projects: It offers a uniform approach for all projects, significantly reducing the learning curve for new developers.
  • Advanced Dependency Management: Maven excels in managing dependencies, including automatic updates and handling transitive dependencies.
  • Simultaneous Multi-project Handling: The tool is adept at managing multiple projects concurrently, enhancing productivity.
  • Extensive Libraries and Metadata Repository: Maven provides immediate access to a vast repository of libraries and metadata, often updated in real-time with major Open Source projects.
  • Customizable and Extensible: Users can easily create plugins in Java or scripting languages, tailoring Maven to their specific needs.
  • Minimal Configuration for New Features: Access new functionalities with little to no additional configuration.
  • Integration with Ant Tasks: Maven integrates seamlessly with Ant tasks for dependency management and deployment beyond its own ecosystem.
  • Model-Based Builds Without Scripting: It utilizes metadata for building projects into predefined outputs like JARs or WARs, eliminating the need for scripting.
  • Automated Documentation and Reporting: Maven can generate websites or PDFs for project documentation and reports, utilizing the same metadata as the build process.
  • Streamlined Release Management: It integrates with source control systems for efficient release management and can publish distributions for external project use.
  • Centralized Dependency Repository: Promotes the use of a central repository for JARs and dependencies, facilitating reuse and backward compatibility.

Next, we’ll dive into the step-by-step process of installing Apache Maven, offering you two distinct methods to fully tap into its capabilities.

Update Fedora Before Apache Maven Installation

Ensuring System Up-to-Date

Before installing Apache Maven, it’s crucial to update and upgrade your Fedora system. This step ensures that all packages are current, reducing potential conflicts during the Maven installation. Execute the following command in the terminal to refresh your system’s package index and upgrade the packages:

sudo dnf upgrade --refresh

This command combines two actions: upgrade updates all installed packages to their latest versions, and --refresh forces a refresh of the repository metadata. It’s important to regularly perform this step to maintain system stability and security.

Install Apache Maven via Fedora Appstream (Default Method)

Initiating Installation Using Fedora’s Default Repository

Installing Apache Maven on Fedora is straightforward with the Fedora Appstream, the operating system’s default repository. This repository typically contains a stable version of Maven, updated biannually to include major version upgrades. This ensures a balance between up-to-date features and system stability.

To install Apache Maven, run the following command in the terminal with root access:

sudo dnf install maven

This command retrieves and installs the latest version of Maven available in Fedora’s default repository. The dnf package manager handles dependencies and version compatibility, streamlining the installation process.

Verifying Maven Installation

Post-installation, it’s important to verify the successful installation of Apache Maven. This step confirms that Maven is correctly installed and operational. In the terminal, execute the following command:

mvn -version

This command displays the installed version of Apache Maven. A successful installation will output the version details, confirming that Maven is ready for use.

Screenshot showing Apache Maven version output in Fedora Linux terminal
Confirming Maven Installation with Version Output in Fedora Terminal

Install Apache Maven on Fedora via Tarball (Latest Version)

Preparing Java Installation

Before installing Apache Maven, ensure Java is installed on your Fedora system. Java is a prerequisite for Maven. Install Java OpenJDK by executing the following command:

sudo dnf install java-openjdk

This command installs the Java OpenJDK package, which Maven requires to function.

Screenshot of Java installation prompt in Fedora Linux
Starting Java Setup for Maven on Fedora Linux

Downloading Apache Maven

To download the latest version of Apache Maven, first, visit the official Apache Maven website to identify the most recent release. Then, use the wget command to download the specified Maven version.

For instance, to download Maven 3.9.6, execute:


This command fetches the specified Apache Maven binary archive and saves it to your local machine.

Extracting and Installing Maven

After downloading, navigate to the directory containing the downloaded file. Extract the contents of the archive using:

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

This command creates a new directory named “apache-maven-3.9.6” containing the extracted files.

Configuring Environment Variables

Temporary Environment Configuration

For one-time use, set the Maven environment variables manually in the terminal:

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

Replace /path/to/maven with the actual path to your extracted Maven directory.

For example:

export M2_HOME=/home/$USER/apache-maven-3.9.6
export PATH=$PATH:$M2_HOME/bin

Replace /path/to/maven with the path to your Maven directory, like /home/$USER/apache-maven-3.9.6.

Permanent Environment Configuration

To permanently add Maven to your environment, append the export commands to your .bashrc file:

echo export M2_HOME=/home/$USER/apache-maven-3.9.6 >> ~/.bashrc
echo export PATH=$PATH:$M2_HOME/bin >> ~/.bashrc

Important Reminder: It’s crucial to enter these commands in the sequence shown above. Reversing the order or mixing them up can lead to problems when attempting to use the mvn command. Correct ordering ensures that your environment variables are set up properly for Maven.

After appending these lines, apply the changes by sourcing the .bashrc file:

source ~/.bashrc

This command updates your session, adding the Maven binaries to your system path.

Verifying Maven Installation

To confirm the successful installation of Maven, check its version with:

mvn -version

This command displays the installed Maven version and its configuration. If the installation is successful, you will see the version details, confirming Maven is ready for use.

Terminal screenshot of Maven version check after manual installation on Fedora
Verifying Maven Version After Manual Setup on Fedora

Create a Test Apache Maven Project on Fedora

Setting Up a New Maven Project

After installing Apache Maven on your Fedora Linux system, validate the installation by creating a test Maven project. Start by creating a new directory for the project and navigating to it in the terminal.

To generate a new Maven project, run:

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

This command sets up a new Maven project with com.example as the group ID and my-project as the artifact ID using the maven-archetype-quickstart archetype. The -DinteractiveMode=false option instructs Maven to skip additional input requests during project creation.

Screenshot of successful creation of a new Maven project in Fedora Linux
Maven Project Initialization Success on Fedora


In this guide, we walked through the essentials of installing Apache Maven on Fedora Linux, covering both the default Appstream method and the manual installation for the latest version. We also touched on how to verify and test your Maven setup by creating a simple project. Remember, keeping your system updated and understanding the basics of Maven’s project structure are key to a smooth experience. As you move forward, Maven will become an invaluable tool for managing your Java projects, simplifying dependency management and build processes. Dive in, explore its features, and you’ll find it enhances your development workflow significantly. Happy coding!

Leave a Comment