Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
VGSources
Blog

How to Install Maven on Ubuntu

Install Maven on Ubuntu with the recommended APT commands, verify Java and Maven, build a first project, or configure a manually downloaded Apache release when you need version control.
Length8 min Posted Quest giverVGSources Team
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The quickest supported setup on Ubuntu is to install a Java Development Kit (JDK), refresh APT’s package index, install Maven, and verify it in a new shell:

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

Use this APT method when Ubuntu’s packaged Maven is suitable. Install Maven manually from an Apache binary archive when you need to select a release independently of Ubuntu’s repository. Both methods require a JDK, not merely a Java runtime.

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.

What Maven does and why Java comes first

Apache Maven is a build and project-management tool commonly used to compile Java code, run tests, package applications, and place built artifacts in a local repository. Maven itself runs on Java, so the first requirement is a Java Development Kit. Apache’s installation guidance states that a JDK is required; installing only a runtime can leave Maven unable to compile projects or start correctly.

Ubuntu’s Java instructions use the default-jdk package for the distribution’s default supported JDK. If you need a particular release, Ubuntu also publishes versioned packages such as openjdk-21-jdk. OpenJDK 17 and OpenJDK 21 are TCK-certified on Ubuntu 24.04 LTS. The package you should choose depends on your Ubuntu release and the Java level required by your project.

#1 Best Overall
Sale
Gaoye Blue Light Blocking Glasses
  • BLUE LIGHT BLOCKING GLASSES: Our blue light glasses for women boast UV400 protection, blocking harmful blue rays from computer screens. With these bluelight glasses women, you can enjoy gaming, reading, or watching TV with no worries of eye strain.
  • EYE RELIEF: Our blue light glasses are engineered to reduce blurry vision or strain caused by prolonged screen time. These womens blue light glasses aid in better sleep by preventing blue light from disrupting your natural sleep cycle, helping you fall asleep faster and enjoy a more restful night's sleep, making them the perfect christmas present.
  • COMFORTABLE: Crafted from durable material, our trendy blue light glasses for woman or blue light glasses men ensure long-lasting comfort. The high-transmittance lenses accessories, gamer gifts for men, help keep your eyes relaxed. Perfect stocking stuffers, gifts for gamers men, christmas gifts for men, halloween costumes.
  • LIGHTWEIGHT: These clear blue light glasses feature a lightweight frame, meaning they’ll stay comfy for long-term wear. Perfect as blue blockers glasses for women or mens blue light glasses, these non-prescription fake glasses for men can be worn throughout the day. The blue light blocking glasses women feature polycarbonate HD lenses, which are anti-reflective and restore true color.
  • WORRY-FREE PURCHASE: If you experience any issues, our support team is ready to assist you quickly. These are the perfect costume glasses for cosplay dressing up.

Before you install

Check whether Java is already available

Run:

java -version
javac -version

The first command checks the Java runtime executable; the second checks the compiler supplied by a JDK. If javac is missing, install a JDK even if java -version prints a version. If both commands work and the JDK is compatible with your project, you can skip installation of default-jdk.

Confirm your Ubuntu package manager can reach its repositories

APT needs current package indexes. An ordinary user account with sudo privileges is also required for package installation. You do not need to download a separate installer for the APT route.

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

Install Maven with APT

APT is Ubuntu’s documented command-line package-management path. It lets Ubuntu track Maven as a system package and receive updates through the same mechanism as other installed software.

  1. Refresh package indexes. Run sudo apt update. This downloads the current metadata for the repositories configured on your system.
  2. Install a JDK when needed. Run sudo apt install default-jdk. Accept the confirmation prompt. If you deliberately need a versioned package, use the appropriate Ubuntu package, for example sudo apt install openjdk-21-jdk.
  3. Install Maven. Run sudo apt install maven and confirm the transaction.
  4. Start a new shell. Close and reopen the terminal, or start a fresh shell process, so command lookup reflects the completed installation.
  5. Verify Maven. Run mvn -v.

The verification output should identify Maven and show the Java runtime Maven is using. It also helps distinguish a missing Maven executable from a Java configuration problem.

Verify the installation in detail

Check Maven’s version report

Use:

mvn -v

Apache recommends this command in a new shell. If it prints Maven and Java information, the executable is discoverable and Maven can start. The Maven version supplied by APT is controlled by your Ubuntu release and current package state; there is no single Maven version shared by every Ubuntu release.

Check which executable is being used

When more than one Java or Maven installation exists, inspect command resolution:

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.
command -v mvn
command -v java
command -v javac

An APT installation normally resolves Maven from a system directory such as /usr/bin. A manually installed copy should resolve from the directory whose bin folder you added to PATH. If the path is unexpected, remove the obsolete PATH entry or adjust the order of entries.

Rank #2
Windex Gaming Cleaning Wipes, Pre-Moistened Wipes to Instantly Clean all Gaming Gear and Electronics, Resealable Packaging for a Freshness Lock, 25 count (Pack of 1)
  • WINDEX GAMING WIPES: effortlessly clean all your gaming gear and gaming electronics in one easy step with our new Windex Gaming Wipes
  • AMMONIA FREE: our ammonia-free formula is safe to use on all of your favorite gaming equipment like consoles, headsets, controllers, screens, keyboards, and more
  • PRE-MOISTENED WIPES: each wipe instantly removes dust, dirt, and stubborn smudges and fingerprints leaving a streak-free shine
  • ANTI-STATIC: great for cleaning and wiping down your gaming gear and electronics leaving behind no visible residue
  • COMPACT RESEALABLE PACKAGE: store your pack of Windex Gaming Wipes anywhere in your home for whenever a quick and easy wipedown is needed

Build a first Maven project

Once mvn -v succeeds, verify that Maven can execute a real build. Ubuntu’s tutorial demonstrates creating a starter project with the Maven archetype command:

mvn archetype:generate

The command is interactive unless you provide all archetype properties. Follow its prompts to create a project directory, group identifier, artifact identifier, and package. The exact prompts can vary with the archetype and Maven version, so read each question rather than assuming a fixed sequence.

For a project that targets Java 8, Ubuntu documents this build command:

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

This compiles the project, runs its unit tests, and creates the package when the build succeeds. The release value belongs to the project you are building; change it only when the source and dependencies support another Java level.

Recognize Maven’s conventional layout

A standard Maven project contains:

  • pom.xml, the project descriptor that declares coordinates, dependencies, plugins, and build settings.
  • src/main/java, the usual location for production Java source.
  • src/test/java, the usual location for test source.
  • target, the build output directory created during a package or test lifecycle.

Running mvn package produces a JAR in target when the project is configured to create one. Running mvn install additionally places the built artifact in your local repository, normally ${user.home}/.m2/repository, so other local Maven builds can resolve it.

APT versus a manual Apache installation

Both approaches install the same build tool, but they put maintenance and version decisions in different places.

Decision area APT installation Manual Apache archive
Maintenance and updates Ubuntu manages the package and updates through APT. You manage downloads, replacement of old releases, and cleanup yourself.
Version control Uses the Maven version available in your Ubuntu repository and package state. Lets you select the Apache archive release you need.
Setup effort Refresh indexes and run package commands. Download a binary archive, extract it, and configure PATH.
Reproducibility across Ubuntu releases Repository versions can differ between Ubuntu releases. The selected archive can be reused across compatible Ubuntu installations, provided its Java requirement is met.

Choose APT for the least administration and the normal Ubuntu integration. Choose the manual route when a project or build environment requires a Maven release that your Ubuntu repository does not provide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #3
Sale
LISEN Cell Phone Stand Phone Holder for Desk, Office Decor Gadgets for Men
  • Ergonomic & Adjustable Design: Fight "text neck" and improve your posture. Designed for comfort, it offers an adjustable height (7.1in-8.5in) (1.4in adjustable range) and angle (5°-85°) Please note: cell phone stand is only 9 inches tall—the length of a standard pencil
  • Without blocking subtitles Perfect for office desk Tiktok Face Time Zoom video—this is the ultimate kitchen desk essential for phones! Perfect viewing experience while reducing neck back strain, A must-have for gamers streamers desk, and anyone who values both style and support!
  • Sleek & Stable Design fits Otterbox Case: Say goodbye to bent cables, tangles, and tip-overs! LISEN’s stylish adjustable desk phone holder features a built-in charging hole and smart cable management, keeping your phone secure and your workspace clutter-free cool gadgets for men
  • ANTI-SLIP DESIGN free hands: The under 10.00 items easy gadgets back and the bottom of this kitchen essentials for women are fully covered by anti-skid silicone, which LISEN stand up desk decor can provide maximum protection device from any scratches and slides
  • Your Perfect Viewing Companion:If your product arrives damaged or breaks within 365 days, reach out to LISEN for a quick and hassle-free solution. Struggling with assembly, like tightening the screw? We’ve got your back! Your experience matters to us. (Product including: phone Holder stand*1, screw*1, hexagon screwdriver*1, specification*1)

Install Maven manually from Apache

The manual procedure is useful when you need an independently selected release. Apache’s documented sequence is to download the binary archive, extract it, add its bin directory to PATH, and run mvn -v in a new shell.

1. Install and verify a JDK

Install default-jdk or a suitable versioned JDK with APT if one is not already present. Maven cannot replace this prerequisite. Verify both java -version and javac -version before changing Maven files.

2. Download the binary archive

Use the Apache Maven installation page to select the release appropriate for your environment. The page cited for this guide shows Maven 3.10.0 as the stable release and states that it requires JDK 8 or newer; software availability changes, so check the page at the time you download rather than assuming that version remains current.

3. Extract the archive

Change to the directory containing the downloaded archive and extract it. For an archive named according to the 3.10.0 release, the command is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
tar -xzf apache-maven-3.10.0-bin.tar.gz

If you downloaded another release, use that archive’s actual filename. Extraction creates a Maven directory whose name includes the release number.

4. Put Maven in a stable location

You can keep the extracted directory in your home directory or move it under a system location such as /opt. A system location generally requires administrative privileges:

sudo mkdir -p /opt
sudo mv apache-maven-3.10.0 /opt/

Adjust the directory name to match the archive you extracted. Keeping the release number in the directory name makes parallel installations possible, but it also means the PATH entry must point to the release you intend to use.

Rank #4
Ledagic IC+RGBW USB Powered Led Light Bar with App & Remote Control, 2 Pack
  • Easy Installation: Our gaming lights have been designed to enhance your entertainment experience. Simply position the led light bar next to your TV or game console to create a game room environment with ease. They come with USB power and a 60 inch cord for direct mounting and mobility
  • Audio Syncing & Extensive Mode: The built-in high-sensitivity music sensor allows you to sync the TV led lights to your favorite music. Lights react and move to the beat of music, film and game audio, creating an incredible immersive sound and light experience – and all without the need for an additional hub. You can choose from 64+ patterns, including strobe, illusion, jump, energy, gradient, running, chasing, fluttering mode etc. Each mode can be applied to different scenes
  • 64+ Chasing IC+RGB & W Effect: The independent control design of IC+RGB and white all-in-one multifunctional rgbw led bar lights monitor backlight allows you to easily switch the led lights for desk between IC+RGB and white to enjoy a variety of lighting effects, you can choose white lighting mode with high brightness for better illumination when working, etc. Choose IC+RGB lighting mode when you need to create an entertaining atmosphere for the light show, 16 million colours of Color changing rgb light bar let you dance to the beat and create a dynamic party atmosphere
  • Dynamic and Dimmable Lights: 1%-full brightness free brightness adjustment gives you the flexibility to adjust dimmable led light bar for room decorations or a variety of occasions
  • USB Powered: USB light bars for room can be powered by powernank, usb charger, TV, Monitor, laptop PC mainframe, making behind TV led lighting bar easy to install in any location.TV led lights are powered by the TV usb interface / PC mainframe, can be turned on/off synchronously with TV / PC

5. Add the extracted bin directory to PATH

For a system-wide location matching the example above, add this line to the startup file used by your shell, such as ~/.bashrc for an interactive Bash session:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
export PATH=/opt/apache-maven-3.10.0/bin:$PATH

Use the real extracted directory name if you selected another release or location. Load the file in the current shell, or open a new terminal:

source ~/.bashrc
mvn -v

Apache specifically calls for checking mvn -v in a new shell. A new shell also catches mistakes where the line was added to a startup file that your current terminal does not read.

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

Troubleshoot common installation failures

“mvn: command not found” after an APT install

  • Open a new shell and run command -v mvn.
  • Check that /usr/bin is present in your PATH, because APT-installed executables are normally placed in a system directory searched there.
  • Run sudo apt update, then retry sudo apt install maven if the package transaction did not complete.

Do not add a manual Maven directory to PATH merely to hide an incomplete APT installation; first confirm which installation you intend to maintain.

“mvn: command not found” after a manual install

  • Verify that the archive was extracted and that its directory contains a bin subdirectory.
  • Check the PATH line for the exact extracted directory and release number.
  • Run source ~/.bashrc or open a new shell, then use command -v mvn.

If command -v mvn still returns nothing, the PATH entry is either in a startup file your shell does not read or points to the wrong directory.

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

Maven says Java is missing

Install a JDK rather than only a runtime:

sudo apt install default-jdk

Then open a new shell and rerun mvn -v. If you selected a versioned JDK, confirm that javac -version reports it. Maven’s requirement is specifically a Java Development Kit.

APT cannot locate Maven or uses stale metadata

Refresh the package index:

sudo apt update

Retry the installation after the command completes. If the package is still unavailable, the repositories configured for that Ubuntu release may not currently expose it; this is a reason to check the release’s repository configuration or consider the manual Apache archive.

Best Value
Sale
HUANUO FlowLift™ Dual Monitor Stand, Fully Adjustable Gaming Monitor Desk Mount for 13–32″ Computer Screens, Full Motion VESA 75x75/100x100 with C-Clamp & Grommet Base, Each Arm Holds 4.4 to 19.8 lbs
  • Compatible with Wide Screens - To ensure compatibility with the dual monitor mount, your each monitor must meet three conditions at the same time: First, computer screens size range: 13 to 32 inches. Second, screen weight range: 4.4 to 19.8 lbs. Third, the back of the monitor screen must have VESA mounting holes with a pitch of 75x75mm or 100x100mm.
  • Regarding the compatibility with desks - Your desk must meet three conditions at the same time: First, desk material: Only wooden desks are recommended, plastic or glass desks cannot be used. Second, desk thickness range: 0.59" - 3.54". Third, the bottom of the desk should not have any cross beams or panels, as this will interfere with installation. We recommend carefully checking that your desk and monitors meets all above conditions before purchasing.
  • Dual C-Clamp Hold - Worried your dual monitors might wobble or slip? Our upgraded base uses a larger platform plus a dual C-clamp structure to lock the dual monitor arm firmly to your desk. Each arm safely keeps your screens steady while you type, click and game—no shaking, no sliding, just a clean and secure setup you can trust every day. It also provides Grommet Mounting installation choice, both options ensure stable and secure fixation for your 0.59" - 3.54" desk.
  • Full-Motion Adjustment For Comfortable View - Pull the screen closer when you’re deep in a spreadsheet, push it back to watch videos, or rotate to portrait for coding — moving everything smoothly with just one hand. The monitor stand offers +85°/-50° tilt, ±90° swivel and 360° rotation. Raise your monitor up to 15.75″ to support a healthy sitting posture. Whether you’re working from home, gaming through the night, or switching between video calls and documents, getting the screens to your natural line of sight helps relieve neck, shoulder and back strain so you can stay focused longer with less fatigue.
  • Keep Your Desk Organized: By lifting both screens off the desktop, this dual monitor stand opens up valuable space for your keyboard, notebook, docking station or a simple, clutter-free work area. Built-in cable management guides wires along the arms, keeping cords out of sight and out of the way. Enjoy a tidy, modern workstation that looks as good as it feels to use.

A project fails even though Maven starts

Separate installation from project compatibility. First run mvn -v to record the Maven and Java versions. Then inspect the project’s pom.xml and compiler settings. A command such as mvn -Dmaven.compiler.release=8 package requests Java 8 bytecode and compilation rules; it does not make a project compatible with every dependency or source level.

Updating, switching, and removing Maven

Updating an APT installation

APT-managed Maven follows Ubuntu’s package updates. Refresh indexes and apply the package update with:

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.
sudo apt update
sudo apt install --only-upgrade maven

The available version remains dependent on your Ubuntu release and configured repositories.

Switching manual releases

Extract the new archive beside the old one, change the PATH entry to the new bin directory, open a new shell, and verify with mvn -v. Keep only the release directories you still need; deleting an old directory that remains first on PATH can make a shell point nowhere.

Removing Maven

For an APT installation, remove the package with:

sudo apt remove maven

For a manual installation, remove the extracted directory and delete its PATH line from the relevant shell startup file. Removing Maven does not remove your JDK or projects, and it does not automatically delete the local repository under ${user.home}/.m2/repository.

Which installation method should you choose?

  • Choose APT when you want the shortest setup, Ubuntu-managed updates, and a Maven version that is acceptable for your projects.
  • Choose the manual archive when you must pin or test a Maven release independently of Ubuntu’s package schedule and are comfortable maintaining PATH and upgrades yourself.
  • Use either method only after selecting a compatible JDK. Maven’s launcher and your project’s compiler settings are separate concerns, so verify both the installed JDK and the project’s required Java release.

Command checklist

For a normal APT installation, the complete sequence is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
sudo apt update
sudo apt install default-jdk
sudo apt install maven
mvn -v

If a supported JDK is already installed, omit the second line. For a manual installation, the essential sequence is: download the Apache binary archive, extract it, add its extracted bin directory to PATH, start a new shell, and run mvn -v. A successful version report is the practical point at which Maven is ready for project commands such as mvn package and mvn install.

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 quests from Patch Notes

  1. How to Set Up a RedM (RDR2) Server in 2026: License Key, txAdmin and server.cfg, Step by StepBlog11min
  2. Best RedM (RDR2) Server Hosting in 2026: Comparing Four Hosts on Slots, Memory and PriceBlog10min
  3. How to Host a Mindustry Server in 2026: server-release.jar, Port 6567 and the Commands That MatterBlog7min
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
PC Slower Than It Used to Be?Free scan - under a minute

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.