Preparing a Java project on Ubuntu or Debian starts with making its build tool available. Apache Maven runs build tasks for Java projects and uses a project file called pom.xml to manage configuration and dependencies.
This article walks through installing Maven with APT and choosing between the distribution package and Apache’s binary archive.
TL;DR: Install Maven on Ubuntu
On Ubuntu or Debian, install the distribution package with APT after confirming that a JDK is available. Choose the Apache binary archive instead when you specifically need the upstream release rather than the version packaged for your distribution.
- Check Java with java -version.
- Install Maven with sudo apt update and sudo apt install maven.
- Confirm the launcher with mvn --version.
What is Apache Maven?
Apache Maven is a build automation tool for Java projects. A project describes its configuration and dependencies in a pom.xml file, and Maven uses that model to run lifecycle tasks such as compiling and packaging.
Maven runs on a Java Development Kit (JDK), which includes the Java runtime and development tools. Its command-line launcher is mvn. The launcher reads project configuration and can download declared dependencies from configured repositories when a build needs them.
For a Java setup first, see how to install Java on Debian and Ubuntu. The Apache Maven overview explains the project model and build lifecycle.
How to install Maven on Ubuntu or Debian
APT installs the Maven version offered by the Ubuntu or Debian repositories configured on your system. This route fits a standard repository installation.
Step 1: Check for a JDK
Maven needs a JDK. Run the Java version check to confirm the shell can find one. Apache Maven 3.10.0 requires JDK 8 or newer, according to its installation guide.
java -version
openjdk version "25.0.4.1" 2026-08-18
OpenJDK Runtime Environment (build 25.0.4.1+1-1-24.04.4-Ubuntu)
OpenJDK 64-Bit Server VM (build 25.0.4.1+1-1-24.04.4-Ubuntu, mixed mode, sharing)
If the shell cannot find java, install a JDK package before continuing. The distribution package is commonly installed with sudo apt install default-jdk. Package names and versions vary by release, so review the proposed version before confirming.
Step 2: Install the Maven package
Refresh the package index and install Maven from your configured repositories.
sudo apt update
sudo apt install maven
These commands require administrator privileges, so I did not execute them here. The read-only package check below confirms the repository candidate without changing the system.
apt-cache policy maven
maven:
Installed: 3.8.7-2
Candidate: 3.8.7-2
Version table:
*** 3.8.7-2 500
500 http://ap-mumbai-1-ad-1.clouds.ports.ubuntu.com/ubuntu-ports noble/universe arm64 Packages
100 /var/lib/dpkg/status
Review the package manager’s confirmation prompt before accepting changes. The package candidate shown above is the version this configured repository will install.
Step 3: Verify the Maven command
Run the version command to confirm that the shell can find Maven and to see which Java runtime it uses.
mvn --version
The command I ran returned this output:
Apache Maven 3.8.7
Maven home: /usr/share/maven
Java version: 25.0.4.1, vendor: Ubuntu, runtime: /usr/lib/jvm/java-25-openjdk-arm64
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "7.0.0-1013-oracle", arch: "aarch64", family: "unix"

The Maven home line identifies the installation directory, while the Java line identifies the runtime Maven picked up. Your version and paths can differ because they depend on the configured repositories and installed JDK.
What to check after installing Maven
After installation, verify Maven from a new shell and check which Java runtime it selects. These checks help separate a missing command from a package-version difference.
| Case | Symptom | Fix |
|---|---|---|
| Maven command is missing | mvn returns “command not found” | Confirm the package finished installing, open a new shell, then run command -v mvn. For a manual archive install, add its bin directory to PATH. |
| Maven version does not meet the project requirement | mvn --version prints an unexpected version | Check apt-cache policy maven and compare the candidate with Apache’s official Maven downloads. Use the archive route if the repository candidate is unsuitable. |
| Maven selects the wrong Java runtime | The Java version or path in mvn --version is unexpected | Run java -version and echo “$JAVA_HOME”. Set JAVA_HOME only when your environment requires an explicit JDK location. |
If the repository candidate does not meet your project requirement, compare it with Apache’s current binary release. Follow the official instructions to extract that archive and add its bin directory to PATH, then verify its checksum or signature using Apache’s published files.
For archive handling, see the Linux tar command guide. Maven’s user-level settings belong in ~/.m2/settings.xml, while project-specific configuration can live in the project’s .mvn directory.
Conclusion: Choose the package that fits your project
Install the APT package when the distribution-managed version meets your project requirements. Confirm the JDK and run mvn --version before building. Use Apache’s current binary instructions when you need a particular upstream release.
For Maven’s install requirements and release files, use the official installation guide and download page.
FAQ
These answers cover the version and verification questions that commonly come up during installation.
How do I check whether Maven is installed?
Run mvn –version. The output includes the Maven version, Maven home, and Java runtime details.
Does APT install the latest Apache Maven release?
Not necessarily. APT installs the version available in your configured Ubuntu or Debian repositories, which can differ from Apache’s current release.
Which Java version does Maven need?
Apache Maven 3.10.0 requires JDK 8 or newer. Check the official installation page for the requirements of the release you choose.
