Installing Apache Maven on Ubuntu: Setup, Verification, and Tips

watch 3m, 6s
views 2

09:02, 26.10.2026

Article Content
arrow

  • Apache Maven Explained
  • Pre-Installation Checklist
  • Installing with APT
  • Step #1: Refresh Package Index
  • Step #2: Install Maven
  • Installing Maven from a Downloaded Archive
  • Step #1: Download the Maven Distribution
  • Step #2: Extract Maven and Create a Symlink
  • Step #3: Set Up Environment Variables
  • Step #4: Confirm the Installation
  • Wrap-Up

Before you start typing build commands and chasing missing libraries, you need a solid foundation. Ideally, you would like your Java projects to build in the same way on every machine. You want fewer surprises and more control. 

Apache Maven provides stability, and Ubuntu offers a clean environment in which to run it. This guide will walk you through the step-by-step installation of Maven, help you verify that everything is working correctly, and provide you with tips along the way.

Apache Maven Explained

If you work with Java projects, you will inevitably encounter Apache Maven at some point. Maven helps you to manage dependencies, build code and maintain consistency across your projects. All you have to do is define what you need in a simple configuration file, and Maven takes care of the rest. This saves you time and helps you avoid the chaos of manual setup. 

Maven remains one of the most trusted build tools in the Java ecosystem, and it works smoothly on Ubuntu.

Pre-Installation Checklist

Check a few things:

  • You need Ubuntu with sudo privileges.
  • You also need Java installed, because Maven runs on the Java Virtual Machine.
  • You can verify Java by running java -version in the terminal. 

Maven officially supports Java 7 and newer, but modern projects usually rely on Java 11 or later. Make sure your system has an active internet connection, since Maven downloads dependencies when you build projects.

Installing with APT

When you install Maven with APT, it gives you speed and simplicity. Ubuntu maintains Maven in its official repositories, so you can trust the source.

Step #1: Refresh Package Index

You must always refresh the package index first. This ensures that Ubuntu recognises the latest available versions. Open your terminal and run the 'sudo apt update' command. This will help your system to stay in sync with the repositories.

Step #2: Install Maven

Now you can install Maven with one command. 

Run sudo apt install maven. Ubuntu resolves dependencies for you and places Maven in the correct system paths. 

After installation, you can check the version with mvn -version. 

You should see Maven details and the Java version it uses.

Installing Maven from a Downloaded Archive

Of course, you may want more control over the Maven version. Manual installation works well when you need a newer release than the one in APT.

Step #1: Download the Maven Distribution

The official Apache website is where you should download Maven. Apache hosts verified binary archives for each release. Select the latest stable version and download the .tar.gz file. This source is trustworthy and up to date.

Step #2: Extract Maven and Create a Symlink

The next step is for the archive to be extracted. A common location for optional software is /opt, so you can place Maven there. After extraction, create a symbolic link to /opt/maven. This lets you upgrade Maven later without changing paths across the system.

Step #3: Set Up Environment Variables

Now you tell Ubuntu where Maven lives. You set the MAVEN_HOME variable and update the PATH. You can place these settings in /etc/profile.d/maven.sh or in your own shell configuration file. This step ensures that you can run mvn from any directory.

Step #4: Confirm the Installation

You should confirm everything works as expected. Run mvn -version again. Maven should report the correct version and detect your Java installation.

At this point, you are ready to build projects.

Wrap-Up

So, you've got Apache Maven up and running on your Ubuntu computer. For convenience, you can choose the APT method, or for flexibility, you can choose the archive method. Both approaches are valid and widely used. With Maven installed, you have a reliable way to manage builds and dependencies. Your Java workflow will become faster, cleaner and far more predictable.

Share

Was this article helpful to you?

VPS popular offers

-10%

CPU
CPU
8 Epyc Cores
RAM
RAM
32 GB
Space
Space
200 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 32768
OS
CentOS
Software
Software
Keitaro

€ 77.54 /mo

€
/mo

Billed annually

sale

-30%

CPU
CPU
6 Xeon Cores
RAM
RAM
8 GB
Space
Space
200 GB HDD
Bandwidth
Bandwidth
Unlimited
KVM-HDD 8192 Linux

€ 25.25 /mo

€
/mo

Billed annually

sale

-30%

CPU
CPU
6 Xeon Cores
RAM
RAM
16 GB
Space
Space
150 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-wKVM-SSD 16384 Windows

€ 237 /mo

€
/mo

Billed monthly

sale

-30%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
100 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 4096 Linux

€ 12.55 /mo

€
/mo

Billed annually

sale

-30%

CPU
CPU
4 Xeon Cores
RAM
RAM
4 GB
Space
Space
50 GB SSD
Bandwidth
Bandwidth
Unlimited
10Ge-KVM-SSD 4096 Linux

€ 60.5 /mo

€
/mo

Billed monthly

-10%

CPU
CPU
6 Epyc Cores
RAM
RAM
8 GB
Space
Space
100 GB NVMe
Bandwidth
Bandwidth
Unlimited
aiKVM-NVMe 8192 Linux

€ 27.96 /mo

€
/mo

Billed annually

sale

-30%

CPU
CPU
10 Epyc Cores
RAM
RAM
64 GB
Space
Space
300 GB NVMe
Bandwidth
Bandwidth
Unlimited
wKVM-NVMe 65536 Windows

€ 139.49 /mo

€
/mo

Billed monthly

sale

-29.9%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
40 GB HDD
Bandwidth
Bandwidth
300 Gb
KVM-HDD HK 1024 Linux

€ 5.02 /mo

€
/mo

Billed annually

sale

-30%

CPU
CPU
3 Xeon Cores
RAM
RAM
1 GB
Space
Space
40 GB HDD
Bandwidth
Bandwidth
300 Gb
wKVM-HDD HK 1024 Windows

€ 10.74 /mo

€
/mo

Billed annually

-10%

CPU
CPU
4 Epyc Cores
RAM
RAM
4 GB
Space
Space
50 GB NVMe
Bandwidth
Bandwidth
Unlimited
Keitaro KVM 4096
OS
CentOS
Software
Software
Keitaro

€ 18.1 /mo

€
/mo

Billed annually

Other articles on this topic

cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.