How to Install Maven on AlmaLinux 10

Published: 2026-06-25
Google AdSense 广告位 (待申请通过后开启)

Introduction

Apache Maven is one of the most popular build automation and dependency management tools for Java applications. It simplifies project builds, dependency downloads, testing, and packaging.

This guide explains how to install Maven on AlmaLinux 10 and verify that it is working correctly.

Prerequisites

Before installing Maven, ensure that Java is already installed on your system.

Check the Java version:

java -version

If Java is not installed, refer to:

* How to Install OpenJDK 21 on AlmaLinux 10

Update System Packages

Update the package repository metadata:

sudo dnf update -y

Install Maven

Install Maven using DNF:

sudo dnf install maven -y
Image-1
Image-1

The installation will automatically download all required dependencies.

Verify the Installation

Check the installed Maven version:

mvn -version
Image-2
Image-2

Example output:

Apache Maven 3.x.x
Maven home: /usr/share/maven
Java version: 21

This confirms that Maven is correctly installed and can locate the Java runtime.

Locate the Maven Installation Directory

Display the Maven executable location:

which mvn

Find the actual path:

readlink -f $(which mvn)

Typical output:

/usr/share/maven/bin/mvn

Create a Test Maven Project

Generate a simple Maven project:

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

Move into the project directory:

cd hello-maven

Build the Project

Compile and package the application:

mvn package
Image-3
Image-3

If the build succeeds, Maven will create a target directory containing the generated JAR file.

Run Maven Tests

Execute unit tests:

mvn test

Where Does Maven Store Downloaded Dependencies?

By default, Maven stores downloaded dependencies in the local repository:

~/.m2/repository

To display the current repository location:

mvn help:evaluate -Dexpression=settings.localRepository -q -DforceStdout
/home/jey/.m2/repository

If all tests pass, Maven will display a BUILD SUCCESS message.

Uninstall Maven

To remove Maven:

sudo dnf remove maven -y

Verify removal:

mvn -version

To remove Maven repository:

rm -rf ~/.m2/repository

You should receive a command not found error.

Conclusion

Installing Apache Maven on AlmaLinux 10 is straightforward using the default DNF repositories. Once installed, Maven can manage project dependencies, automate builds, and simplify Java application development.

Related AlmaLinux 10 Tutorials

How to Install OpenJDK 21 on AlmaLinux 10

How to Install Gradle on AlmaLinux 10

How to Install Git on AlmaLinux 10

Explore More

Technology Guides →

Southeast Asia Insights →