October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk9 min

How to Install Maven on Ubuntu

A complete Ubuntu Maven installation guide covering the JDK prerequisite, APT commands, manual Apache setup, verification, first project build, and common PATH and Java errors.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The dependable Ubuntu installation is the APT route: refresh package indexes, install a Java Development Kit, install Maven, then open a new shell and run mvn -v. This guide explains the exact commands, how to choose a JDK, when a manual Apache installation makes sense, how to create and build a test project, and how to fix the failures users most often meet.

What you need before installing Maven

Apache Maven is a build and dependency-management tool for Java projects. Maven itself is not a Java runtime; Apache’s installation documentation explicitly requires a Java Development Kit (JDK). A JDK supplies the tools Maven needs to compile and test code, so installing only a runtime is not enough for a normal development setup.

As an Amazon Associate I earn from qualifying purchases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

You need an Ubuntu account that can run commands with sudo, a working network connection for package downloads, and enough disk space for the packages and any project dependencies Maven later downloads. The commands below use Ubuntu’s standard APT package manager.

Choose a JDK package

For the least decision-making, install Ubuntu’s moving default package:

#1 Best Overall
Sale
TOZO A1 Wireless Earbuds Bluetooth 5.3 Light Weight in Ear Headphones | IPX5 Waterproof,2 Mics for AI Calls,Immersive Premium Sound Bass Headset with Charging Case,32 EQ via App Black
  • [Ultra-Lightweight Ear Buds Designed for Small Ears] Each earbud weighs only 3.7g and features a compact, ergonomic in-ear design made especially for small ears. Secure, low-profile, and comfortable for workouts, all-day wear or overnight sleeping.The ultra-slim profile sits flush in your ear with no hard edges poking or rubbing, so you can even sleep on your side without discomfort.
  • [Immersive Stereo Sound with TOZO OrigX Technology] TOZO OrigX tuning delivers clear vocals, balanced mids, and natural stereo sound for music, podcasts, and videos.
  • [Long Battery Life for Daily Use] Get up to 7 hours of playtime on a single charge, with up to 32 hours total using the charging case—ideal for workdays, commuting, and extended listening sessions.
  • [Bluetooth 5.3 & Stable Connection] Bluetooth 5.3 provides fast pairing, stable wireless performance, and reduced dropouts as you move around home or office.
  • [Deep Bass with Clear Vocals] High-performance drivers produce punchy bass while keeping vocals clean and detailed for everyday listening.
sudo apt install default-jdk

If you need a specific Java release, Ubuntu also publishes versioned packages. For example:

sudo apt install openjdk-21-jdk

Ubuntu’s Java guidance identifies OpenJDK 17 and OpenJDK 21 as TCK-certified on Ubuntu 24.04 LTS. The package available to you still depends on your Ubuntu release and configured repositories. If a supported JDK is already installed, you can skip the JDK installation step and proceed to Maven.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Install Maven with APT

APT is the normal Ubuntu path because Ubuntu manages the package and its updates. Run the commands in this order:

  1. Refresh the local package indexes:

    sudo apt update

    This downloads current package metadata. It does not install upgrades by itself.

  2. Install a JDK if you do not already have one:

    sudo apt install default-jdk

    When APT asks for confirmation, review the package list and continue. To use a versioned JDK instead, install the appropriate package, such as openjdk-21-jdk, rather than installing both packages unnecessarily.

  3. Install Maven:

    sudo apt install maven

    APT resolves Maven’s package dependencies and places the executable where Ubuntu’s normal system PATH can find it.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  4. Start a new shell and verify the installation:

    mvn -v

    Apache’s instructions use this command as the confirmation step. It should report Maven and the Java environment visible to that shell. Running it in a newly opened terminal also makes sure any environment changes made by package installation are loaded.

    Rank #2
    Sale
    Smart Watch for Men Women Compatible with iPhone Samsung Android Phone 1.69 inch Full Touch Screen IP68 Waterproof Bluetooh Fitness Tracker Heart Rate/Sleep Monitor (Black)
    • 【IP68 Waterproof Multifunctinal Smart Watch】Torjalph fitness activity tracker smart watch is IP68 waterproof technology ,you can wear it when swimming,handwashing,it's rain-proof which means that you perform multiple exercise modes outside without worrying about sweat or rain corroding your fitness smart watch,and this watch equipped with a 230 mAh large capacity battery magnetic charging ,and this sports activity tracker watch can be used 5-7 days If fully charged.
    • 【Larger 1.83'' Full Screen Watch & Multi-dial Selection】1.83 inch full HD color touch screen smart watch for men / women provides excellent 240*284 resolution image quality ,This Bluetooth smart watch offers a better touch experience and remarkable immersion and ,more than 200 watch faces for you to choose from App"Da Fit ", you can change the dial style according to your mood to wear keeping the world on your wrist
    • 【Accurate Activity Tracker Smart Watch 】sports watch activity tracker uses sweat and dust resistant breathable silicone strap, our Fitness Tracker Smart Watch for Android iOS Phones supports 12 sports modes,walking,running,bicycle,swimming,badminton,basketball,football,rope skipping. This bluetooth calls smart watch for men women is lightweight and stylish, bringing more convenient and relaxing sports experience while also providing more protection.
    • 【Your 24 Hour Personal Daily Health Monitor】Fitness watch for women men full touch screen IP67 waterproof bluetooth smartwatch for Android iOS Phones with heart rate blood pressure monitor multifunction Andriod smart watch with steps counter sleep monitor sports fitness watch, monitoring blood oxygen saturation allows you to understand your physical condition in real time to track fitness progress ,to know your health status in time.
    • 【More Functions Bluetooth Call Smart Watch】This fitness activity smart watch full screen for iPhone and Android phones includes a bunch of new features including:The bluetooth smart watch can hang up the phone, receive and display WhatsAPP /Text /Facebook /Twitter /Messenger reminder.Support sedentary reminder, alarm clock, stopwatch, timer,weather information,music control, remote camera control compatible with Android 5.0 and above or iOS 9.0 and above smartphones.

Run the commands as one sequence

If you know that the default JDK is the right choice for your project, the complete sequence is:

sudo apt update
sudo apt install default-jdk
sudo apt install maven
mvn -v

Keeping the commands separate makes failures easier to diagnose: an index problem appears during apt update, a Java package problem during the JDK step, and a Maven package problem during the final installation.

APT or a manual Apache Maven installation?

Both methods install Maven, but they suit different needs. APT is simpler and lets Ubuntu track the package. A manual installation lets you select an Apache archive that may be newer than the version packaged for your Ubuntu release, or lets a team standardize on a particular Maven release.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Decision point APT package Manual Apache archive
Maintenance Ubuntu’s package manager handles installation and updates. You monitor releases and replace the extracted directory yourself.
Version control You receive the Maven version available in your Ubuntu repository and package state. You select the Apache archive version you need.
Setup effort Refresh indexes, install the JDK, install Maven, and verify. Download the binary archive, extract it, configure PATH, open a new shell, and verify.
Reproducibility across Ubuntu releases Repository contents can differ between Ubuntu releases. The selected archive can be reused across compatible systems, provided the required JDK is present.

There is no single Maven version that applies to every Ubuntu release. Repository versions vary with the Ubuntu release and the package state at the time of installation. If you do not have a concrete reason to pin Maven, APT is the lower-maintenance choice.

Install Maven manually from Apache

Use the manual route when you need an Apache release that is outside your distribution repository or you must control the exact Maven archive. Apache’s documented workflow is deliberately straightforward: obtain the binary archive, extract it, add its bin directory to PATH, and run mvn -v from a new shell.

1. Select and download the archive

Check Apache’s Maven installation page at the time you install. The release shown in the referenced Apache documentation is Maven 3.10.0, and that page describes it as requiring JDK 8 or newer; release availability can change, so do not assume that number remains current. Download the binary archive for the release you intend to use, not a source archive.

2. Extract the archive

Move to the directory where the download was saved and extract it with the tool appropriate to the archive format. For a typical .tar.gz download, the command has this form:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
New Bee Guitar Cable 10ft Electric Instrument Bass AMP Cord
  • [Low Noise High Fidelity] New bee guitar cord with 22AWG oxygen-free-copper center conductors provides enhanced signal transfer, the PVC insulation material and the high-density stranded copper double shield provide noise rejection for quiet operation
  • [Ideal for Choice] New bee 1/4 straight and right angle metal connectors, ensures a secure connection in any instrument, pedal, or amp jack. L shape great fro on stage guitar stands
  • [Wide Compatible] Suitable for mixer, power amplifier, microphone, effector, decoder, equalizer, electoronic organ, electric guitar, electric bass and other electronic equipments. Widely used in the installation of smart home, karaoke speaker, professional stage audio, etc
  • [Easy Disassemble] Making incidental repairs quick and easy! Very nice, flexible cable
  • [Dont Hesite to Order] 24 hours customer services and professional technology team are standing by
tar -xzf apache-maven-3.10.0-bin.tar.gz

Replace the filename with the archive you actually downloaded. Extraction creates a Maven directory containing bin, libraries, and supporting files. A shared location such as /opt can work for system-wide administration; a directory under your home directory avoids changing system-owned files and is convenient for a single user.

3. Add Maven’s bin directory to PATH

Add the extracted directory’s bin subdirectory to the shell’s PATH. For an extraction under your home directory, an example is:

export PATH="$HOME/apache-maven-3.10.0/bin:$PATH"

Use the real extraction directory and release name in that command. This change affects the current shell. To make it persistent, place the equivalent export in the startup file used by your shell, then open a new terminal. The important part is that the path points to Maven’s bin directory, not merely to the directory above it.

4. Verify the manual installation

Open a new shell after changing PATH and run:

mvn -v

If the command prints Maven and Java details, the shell can find the selected Apache installation and Maven can see a JDK. If the command is not found, return to the PATH troubleshooting section below before changing the installation.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Verify Java and Maven are using the environment you expect

Verification is more than checking that a file exists. Maven must be executable and must be able to locate a JDK. Run mvn -v in the same kind of shell you will use for builds. This catches a common mismatch in which Maven was installed correctly but a GUI terminal, remote session, or service has a different environment.

  • APT installation: the command should resolve through the system path, normally including /usr/bin.
  • Manual installation: the command should resolve through the extracted Maven bin directory that you added to PATH.
  • Java prerequisite: Maven must see a JDK, not only a Java runtime. If Maven reports that Java is missing, install default-jdk or the versioned JDK package required by your project, then start a new shell and retry.

Create and build a first Maven project

Once mvn -v succeeds, Ubuntu’s tutorial demonstrates generating a project with Maven’s archetype command:

mvn archetype:generate

The archetype command creates a starter project through Maven’s generation process. Follow its prompts to select the project coordinates and confirm the generated layout. The exact prompts and defaults can vary with the archetype and Maven version, so read each prompt rather than assuming a particular value.

Rank #4
BSIMB 15.6" Digital Family Calendar & Chore Chart, No Subscription Fees
  • Digital Family Calendar: BSIMB digital calendar wall touch screen puts an end to your chaotic life. Designed for busy families, the digital calendar keeps you organised and in step with your family. Assign different colours and tasks to each family member to make family scheduling easier and more intuitive.
  • Easy Setup and Auto-Sync: Plug in, connect to WLAN and auto-syn your electric calendar in minutes. Digital wall calendar compatible with Google calendar, iCloud calendar, Outlook calendar, Cozi calendar and Yahoo calendar. Add events directly on the device or through the ecalendar app. Electronic calendar stays current whether you're at work or traveling—no manual updates needed.
  • All-In-One Home Assistant: Smart calendar builds habits and encourage independence with personalised chores. Display daily meal plan to reduce the daily ‘What's for dinner?’ stress. To-do lists keep track of everything you want. Turning chores into valuable achievements with stars and rewards, making life easier and more enjoyable.
  • Manage Anytime Anywhere: BSIMB electronic calendar for family stay connected with the powerful ecalendar app. Access and manage your digital wall calendar anytime, anywhere with free features like stars & rewards, photo screensaver, chore charts, meals plans, to-do lists etc. Electronic planner paid features like Magic Import tailor advanced tools for users with special needs.
  • Stay in Touch with Loved Ones: Share photos or videos from your phone to electronic wall calendar with app, instantly update your life moment, and keep in touch with your family, especially those who are far away; you can also surprise your smart calendar digital wall by sending him a wish card; it's also great for keeping tech-illiterate elders in touch with the youngsters.

Build the generated project

To compile the project, run its tests, and package the result while targeting Java release 8, use:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
mvn -Dmaven.compiler.release=8 package

The package phase compiles the source, runs the unit tests configured for the project, and produces the packaged artifact. The explicit compiler-release property matters when the project is intended to produce Java 8-compatible output even though the installed JDK is newer.

Understand the conventional layout

Maven relies on conventions so that a project can build without a large amount of custom configuration. The conventional files and directories are:

Path Purpose
pom.xml The project descriptor containing coordinates, dependencies, plugins, and build configuration.
src/main/java Production Java source code.
src/test/java Java unit tests.
target Build output, including the packaged JAR created by the package phase.

Package versus install

mvn package creates a JAR in the project’s target directory. Use mvn install when you also want Maven to place that artifact in the local repository, normally ${user.home}/.m2/repository. Installing locally is useful when another local project needs to resolve the artifact by its Maven coordinates.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Troubleshoot installation failures

“mvn: command not found” after an APT install

First open a new shell and run mvn -v again. For an APT installation, check that /usr/bin is included in the shell’s PATH. If it is missing, the shell environment—not Maven’s package contents—is the immediate problem. Correct the environment, start a new shell, and retry.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

“mvn: command not found” after a manual install

Confirm that the extracted directory really contains a bin directory and that your export points to that directory. A frequent mistake is adding the archive’s parent directory or typing a release directory name that does not match the extracted folder. Reapply the export with the correct path, open a new shell, and run mvn -v.

Maven says Java is missing

Maven requires a JDK. Install one with:

sudo apt install default-jdk

Or install the specific Ubuntu package your project requires, such as:

sudo apt install openjdk-21-jdk

After installation, open a new shell and run mvn -v. Installing only a runtime does not satisfy the JDK requirement used for compiling and building projects.

APT cannot locate Maven

Refresh package metadata and retry:

sudo apt update
sudo apt install maven

If the problem persists, the package availability is tied to your Ubuntu release and configured repositories. Do not infer that every Ubuntu release exposes the same Maven version or package state.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The build fails even though Maven installed

Separate installation from project configuration. First run mvn -v in the project shell to confirm Maven and Java are visible. Then inspect the project’s pom.xml, source level, dependencies, and tests. If the project is intended for Java 8, retry the documented build form:

mvn -Dmaven.compiler.release=8 package

A successful installation only proves that Maven can start; it does not guarantee that every project’s compiler settings, dependencies, or tests are correct.

The manual version is not the one you expected

Multiple Maven directories can coexist after repeated manual installations. Check the PATH entry and remove or reorder older Maven bin directories so the intended one appears first. Then open a new shell and verify with mvn -v. For teams that do not need a selected Apache archive, switching back to the APT package reduces this version-management work.

Which installation method should you use?

Choose APT when maintenance matters most

APT is the practical default for a personal Ubuntu workstation, classroom machine, or server where you want Ubuntu to manage updates. The setup is short, the executable is placed on the normal system path, and package maintenance stays in the same workflow as the rest of the operating system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose the Apache archive when version control matters most

Use the manual method when a build system, project requirement, or team policy calls for a particular Maven release that is not the one in your Ubuntu repository. Record the selected release and the extraction path, keep the PATH change explicit, and plan how you will replace the directory when upgrading.

Do not mix methods casually

Installing an APT Maven package and then adding a different manual Maven directory to PATH can make it unclear which executable is running. Pick the method that matches your requirement, or document the PATH order and verify the result with mvn -v whenever you change it.

Command checklist

  • Refresh package indexes with sudo apt update.
  • Install a JDK with sudo apt install default-jdk, or choose a versioned package such as sudo apt install openjdk-21-jdk.
  • Install Maven with sudo apt install maven.
  • Open a new shell and run mvn -v.
  • For a first project, generate a starter with mvn archetype:generate.
  • Build and test it with mvn -Dmaven.compiler.release=8 package.
  • Use mvn install when the artifact also needs to be placed in the local Maven repository.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.