How to Install Apache Maven on Fedora 44

Install Apache Maven on Fedora 44 using DNF or tarball methods. Complete guide with Java setup, automation, and verification steps.

Last updatedAuthorJoshua JamesRead time7 minGuide typeFedora

Install Apache Maven on Fedora when Java projects need a repeatable build tool for dependency resolution, test execution, packaging, and release workflows. Maven reads each project’s pom.xml, downloads required libraries from Maven Central or your configured repositories, and runs lifecycle phases such as compile, test, and package without hand-written shell glue.

Fedora’s DNF package is the best starting point because it installs Maven and the needed OpenJDK packages through the normal system update flow. The official Apache tarball remains useful when a project needs the newest upstream Maven 3.x release or a pinned Maven version independent of Fedora’s repository cadence.

Install Apache Maven on Fedora

Choose an Apache Maven Method on Fedora

Use DNF for most Fedora systems. Choose the official tarball only when you need an upstream Maven release newer than the Fedora package or you want to keep Maven under /opt for a controlled build environment.

MethodSourceUpdate PathBest Fit
DNF packageFedora maven packageUpdated with normal DNF upgradesMost Fedora users and CI hosts
Official tarballApache Maven downloadsManual download, checksum verification, and symlink updateNewest upstream Maven 3.x or pinned project versions

The Apache name in Apache Maven refers to the Apache Software Foundation project, not the Apache HTTP Server. Fedora’s web server package is httpd; use the separate guide to install Apache HTTPD on Fedora if you need the web server instead.

Apache publishes both .tar.gz and .zip binary archives. The Fedora commands here use the .tar.gz archive because it works naturally with Fedora’s standard shell tools and keeps the installed files under one versioned directory.

Refresh Fedora Before Installing Maven

Refresh repository metadata and apply pending package updates before installing Maven:

sudo dnf upgrade --refresh

The --refresh option tells DNF to reload package metadata before resolving the transaction, which avoids stale package lists on systems that have not updated recently.

Install Apache Maven with DNF

Install Maven from Fedora’s default repositories:

sudo dnf install maven

Fedora resolves Maven’s Java dependencies during the transaction. On the current Fedora package set, the Maven package installs the Maven wrapper package for OpenJDK 25 and pulls in the matching OpenJDK development package when it is not already present.

Confirm the installed RPMs when you want package-level proof:

rpm -q maven maven-openjdk25 java-25-openjdk-devel

Current Fedora output uses this package shape:

maven-3.9.11-11.fc44.noarch
maven-openjdk25-3.9.11-11.fc44.noarch
java-25-openjdk-devel-25.0.3.0.9-1.fc44.x86_64

Verify the active Maven binary and Java runtime:

mvn -version

The version, kernel, and locale lines can differ after Fedora updates, but Maven home should point to Fedora’s packaged location:

Apache Maven 3.9.11 (Red Hat 3.9.11-11)
Maven home: /usr/share/maven
Java version: 25.0.3, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-25-openjdk
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "7.0.6-200.fc44.x86_64", arch: "amd64", family: "unix"

Install Apache Maven from the Official Tarball

The tarball method installs Maven under /opt and uses Apache’s checksum file to verify the downloaded archive before extraction. Do not install both methods unless you intentionally want a packaged Maven under /usr/bin and a manually managed Maven under /opt.

Install Java and Download Tools for Maven

Install the OpenJDK development package and download tools needed by the tarball workflow:

sudo dnf install java-25-openjdk-devel curl tar gzip

Maven 3.9 runs on JDK 8 or newer, but a full JDK is still the practical choice for Fedora build hosts because Maven projects often need javac, jar, and related development tools. If you manage several Java branches, keep java, javac, and JAVA_HOME aligned so Maven does not run with one JDK while compiling with another.

Detect the Current Apache Maven 3 Release

Use Apache’s Maven download page as the release source and extract the current Maven 3 binary tarball version:

cd /tmp || exit
MAVEN_VERSION=$(curl -fsSL https://maven.apache.org/download.cgi | grep -oE 'apache-maven-3\.[0-9.]+-bin\.tar\.gz' | head -n 1 | sed -E 's/apache-maven-([0-9.]+)-bin\.tar\.gz/\1/')
if [ -z "$MAVEN_VERSION" ]; then
  echo "Could not detect the current Maven 3 release." >&2
  exit 1
fi
printf 'Maven version: %s\n' "$MAVEN_VERSION"

The curl command in Linux retrieves the Apache page, while grep command filtering and sed command substitution keep only the Maven 3 tarball version. The command prints the release it finds before the download steps reuse the same variable.

Download and Verify the Maven Tarball

Download the binary tarball and its SHA-512 checksum from Apache:

curl -fsSLO "https://dlcdn.apache.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz"
curl -fsSLO "https://downloads.apache.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz.sha512"

Apache’s SHA-512 file contains only the hash, so pair it with the local filename before running sha512sum:

printf '%s  apache-maven-%s-bin.tar.gz\n' "$(cat "apache-maven-$MAVEN_VERSION-bin.tar.gz.sha512")" "$MAVEN_VERSION" | sha512sum -c -

A successful verification prints an OK result for the downloaded archive:

apache-maven-3.9.15-bin.tar.gz: OK

Extract Maven Under /opt

Extract the verified archive and point /opt/maven at the active version:

sudo tar -xzf "apache-maven-$MAVEN_VERSION-bin.tar.gz" -C /opt
sudo ln -sfn "/opt/apache-maven-$MAVEN_VERSION" /opt/maven

The symbolic link lets future tarball updates switch Maven versions without rewriting every shell profile. The archive is a standard .tar.gz file; the guide to open gz and tgz files in Linux explains the archive format if you need more background.

Add Maven to the System PATH

Create a profile script that makes the manually installed Maven binary available in new login shells:

sudo tee /etc/profile.d/maven.sh > /dev/null <<'EOF'
export MAVEN_HOME=/opt/maven
export PATH=$MAVEN_HOME/bin:$PATH
EOF

Load the profile script in the current shell, or open a new terminal session:

source /etc/profile.d/maven.sh

Confirm the shell resolves the tarball-managed Maven first:

command -v mvn
mvn -version

The tarball method should report Maven home under /opt:

/opt/maven/bin/mvn
Apache Maven 3.9.15 (98b2cdbfdb5f1ac8781f537ea9acccaed7922349)
Maven home: /opt/maven
Java version: 25.0.3, vendor: Red Hat, Inc., runtime: /usr/lib/jvm/java-25-openjdk
Default locale: en_AU, platform encoding: UTF-8
OS name: "linux", version: "7.0.6-200.fc44.x86_64", arch: "amd64", family: "unix"

Build a Test Apache Maven Project on Fedora

A sample project verifies more than the mvn command path. It confirms Maven can reach Maven Central, resolve plugins, create a project structure, and produce a JAR.

cd ~
mvn -B archetype:generate \
  -DgroupId=com.example \
  -DartifactId=maven-check \
  -DarchetypeArtifactId=maven-archetype-quickstart \
  -DinteractiveMode=false
cd maven-check
mvn -B package

Java 25 can print deprecation warnings from Maven’s dependency stack before the build logs continue. Treat the final build status as the success signal:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------

The generated project includes pom.xml, Java source files under src/main/java, test files under src/test/java, and a packaged JAR under target/. Remove the sample directory when you no longer need it:

cd ~
rm -rf maven-check

For real projects, install Git on Fedora before cloning source repositories, and install Docker on Fedora when your Maven builds depend on containerized databases, test services, or deployment images.

Manage Apache Maven Updates on Fedora

Update DNF-Installed Maven

DNF-managed Maven updates with Fedora packages:

sudo dnf upgrade --refresh maven

A normal full-system upgrade also updates Maven when Fedora publishes a new package build:

sudo dnf upgrade --refresh

Update Tarball-Installed Maven

For the tarball method, repeat the Apache version detection and checksum verification, then repoint /opt/maven only when a newer Maven 3 release exists:

cd /tmp || exit
MAVEN_VERSION=$(curl -fsSL https://maven.apache.org/download.cgi | grep -oE 'apache-maven-3\.[0-9.]+-bin\.tar\.gz' | head -n 1 | sed -E 's/apache-maven-([0-9.]+)-bin\.tar\.gz/\1/')
CURRENT_VERSION=$(/opt/maven/bin/mvn -version 2>/dev/null | sed -n 's/^Apache Maven \([0-9.]*\).*/\1/p' | head -n 1 || true)

if [ -z "$MAVEN_VERSION" ]; then
  echo "Could not detect the current Maven 3 release." >&2
  exit 1
fi

printf 'Current: %s\nLatest:  %s\n' "${CURRENT_VERSION:-none}" "$MAVEN_VERSION"

if [ "$CURRENT_VERSION" = "$MAVEN_VERSION" ]; then
  echo "Maven is already current."
  exit 0
fi

curl -fsSLO "https://dlcdn.apache.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz"
curl -fsSLO "https://downloads.apache.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz.sha512"
printf '%s  apache-maven-%s-bin.tar.gz\n' "$(cat "apache-maven-$MAVEN_VERSION-bin.tar.gz.sha512")" "$MAVEN_VERSION" | sha512sum -c -
sudo tar -xzf "apache-maven-$MAVEN_VERSION-bin.tar.gz" -C /opt
sudo ln -sfn "/opt/apache-maven-$MAVEN_VERSION" /opt/maven
mvn -version

Do not run tarball upgrades unattended from cron. Maven version changes can affect plugins, build extensions, wrapper expectations, and CI output, so review the Maven release history before switching production build hosts to a new upstream release.

Troubleshoot Apache Maven on Fedora

Maven Command Not Found

If mvn is missing after a DNF install, confirm the package is installed:

rpm -q maven
command -v mvn

If the RPM is installed but the command is missing, reinstall the package:

sudo dnf reinstall maven

For tarball installs, confirm the profile script exists and load it in the current shell:

cat /etc/profile.d/maven.sh
source /etc/profile.d/maven.sh
command -v mvn

If command -v mvn still returns nothing, open a new terminal session and check that /opt/maven/bin appears before any older Maven path in $PATH.

Maven Uses the Wrong Java Version

Check the Java binary Maven sees and compare it with Maven’s runtime line:

readlink -f "$(command -v java)"
mvn -version

If multiple JDKs are installed, switch both the runtime and compiler alternatives so Maven and javac stay aligned:

sudo alternatives --config java
sudo alternatives --config javac

Some plugins also read JAVA_HOME. Derive it from the active Java binary instead of hardcoding a stale path:

JAVA_HOME=$(dirname "$(dirname "$(readlink -f "$(command -v java)")")")
printf 'export JAVA_HOME=%s\n' "$JAVA_HOME" | sudo tee /etc/profile.d/java-home.sh > /dev/null
source /etc/profile.d/java-home.sh
printf '%s\n' "$JAVA_HOME"

Fedora’s Java alternatives and permanent JAVA_HOME setup have more edge cases than Maven itself, especially when pinned and rolling OpenJDK packages coexist. Keep build hosts on a documented JDK branch instead of letting each project inherit whichever Java binary appears first in $PATH.

Maven Dependency Downloads Fail or Use Stale Cache

From the project directory that contains pom.xml, force Maven to check remote repositories again before deleting anything:

cd /path/to/your-project
mvn -U clean package

If a dependency cache is corrupted, run Maven’s dependency purge from the same project root so the plugin can read the project’s dependency graph:

mvn dependency:purge-local-repository

Deleting ~/.m2/repository removes downloaded dependencies for your Linux account. Keep project source code and private settings files intact unless you intentionally want a full Maven reset.

rm -rf ~/.m2/repository

Rebuild the project after clearing the cache so Maven downloads fresh artifacts:

mvn -U clean package

Maven Needs a Proxy for Downloads

Corporate networks often require Maven to use an HTTP proxy before it can reach Maven Central. Create a user-level settings file and replace the host and port with your organization’s proxy details:

mkdir -p ~/.m2
cat > ~/.m2/settings.xml <<'EOF'
<settings>
  <proxies>
    <proxy>
      <active>true</active>
      <protocol>http</protocol>
      <host>proxy.example.com</host>
      <port>8080</port>
    </proxy>
  </proxies>
</settings>
EOF

Then test with a command that must contact Maven Central:

mvn -U help:effective-settings

Old Maven Download URLs Return 404

Apache’s main CDN carries current release assets, so older direct URLs such as apache-maven-3.9.6-bin.zip can stop working from dlcdn.apache.org. Use the Apache Maven 3 archive when you must retrieve an old release for compatibility testing, and prefer the current download page for normal Fedora installations.

Remove Apache Maven from Fedora

Remove DNF-Installed Maven

Remove the Fedora Maven package with DNF:

sudo dnf remove maven

DNF may report unused Java or Maven library dependencies after removal. Review the transaction carefully before confirming an autoremove cleanup:

sudo dnf autoremove

Verify that the package is gone:

if rpm -q maven > /dev/null 2>&1; then
  echo "maven is still installed"
else
  echo "maven is not installed"
fi
maven is not installed

Remove Tarball-Installed Maven

Remove the manually installed Maven directory, active symlink, and profile script:

sudo rm -rf /opt/apache-maven-* /opt/maven
sudo rm -f /etc/profile.d/maven.sh
hash -r
command -v mvn || echo "mvn command not found"

If the current shell still resolves an old Maven path, open a new terminal session after removing the profile script.

Remove Maven Cache and User Settings

The next command permanently deletes your Maven settings, downloaded dependencies, credentials stored in settings.xml, and local cache for the current Linux account. Back up any private repository credentials or custom mirror settings first.

rm -rf ~/.m2

Conclusion

Apache Maven is now ready on Fedora through either the low-maintenance DNF package or a verified upstream tarball under /opt. Use DNF for routine developer systems, choose the tarball for pinned upstream versions, and keep Java selection explicit when projects depend on a specific JDK. For adjacent toolchains, you can also install Go on Fedora.

Share this guide

Help another Linux user troubleshoot faster

Share this guide with someone troubleshooting Linux systems or saving it for later.

Follow LinuxCapable

Want more LinuxCapable guides in Google?

Add LinuxCapable as a preferred source so Google can show more of our fresh Linux tutorials in Top Stories and From your sources when relevant.

Add LinuxCapable as a preferred source on Google
Search LinuxCapable

Need another guide?

Search LinuxCapable for package installs, commands, troubleshooting, and follow-up guides related to what you just read.

Found this guide useful?

Support LinuxCapable to keep tutorials free and up to date.

Buy me a coffeeBuy me a coffee
Before commenting, please review our Comments Policy.
Formatting tips for your comment

You can use basic HTML to format your comment. Useful tags currently allowed in published comments:

You type Result
<code>command</code> command
<strong>bold</strong> bold
<em>italic</em> italic
<blockquote>quote</blockquote> quote block

Got a Question or Feedback?

We read and reply to every comment - let us know how we can help or improve this guide.

Verify before posting: