Menu
User

DropVPS Team

Writer: Cooper Reagan

How to Install Maven on macOS 2025

How to Install Maven on macOS 2025

Publication Date

10/28/2025

Category

Articles

Reading Time

3 Min

Table of Contents

Apache Maven is a powerful build automation and project management tool widely used in Java development. It simplifies dependency management, project builds, and deployment — making it essential for any Java developer’s toolkit. If you’re using macOS 2025, here’s the easiest and cleanest way to install and configure Maven on your system.

Check for Java Installation

Maven requires Java (JDK) to run. Check whether Java is already installed:

java -version

If you get an error like “command not found,” install OpenJDK using Homebrew (recommended):

brew install openjdk

Once installed, verify:

java -version

You should see output similar to:

openjdk version "21.0.x"

Install Homebrew (If Not Installed)

Homebrew is the package manager for macOS and the easiest way to install Maven.
Check if Homebrew is already installed:

brew --version

If not, install it with:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After installation, ensure your shell recognizes it:

echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Install Maven via Homebrew

Now install Maven with one simple command:

brew install maven

Homebrew automatically downloads and configures Maven for you.

Check that Maven is installed successfully:

mvn -version

You should see something like:

Apache Maven 3.9.x
Java version: 21.x
OS name: Mac OS X, version: 14.x

Verify Environment Variables (Optional)

Homebrew usually sets everything automatically, but you can manually confirm the M2_HOME and PATH variables.

Open your shell profile (.zshrc or .bash_profile):

nano ~/.zshrc

Add the following lines if missing:

export M2_HOME=/opt/homebrew/Cellar/maven/3.9.x/libexec
export PATH=$M2_HOME/bin:$PATH

Save and reload the profile:

source ~/.zshrc

Then confirm again:

mvn -version

Create a Sample Maven Project

Test your Maven setup by creating a new Java project:

mvn archetype:generate -DgroupId=com.example -DartifactId=myapp -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

Move into the new project directory:

cd myapp

Compile it:

mvn package

If everything is configured properly, Maven will build your project and generate a .jar file in the target/ directory.

Updating Maven

To keep Maven up to date, run:

brew upgrade maven

Homebrew ensures you always have the latest stable version.

Installing Apache Maven on macOS 2025 is quick and efficient with Homebrew. Once set up, you can easily build, manage, and deploy Java projects with full control over dependencies and plugins. For developers building and deploying on the cloud, check out DropVPS — providing fast, secure, and scalable servers optimized for Java, Maven, and CI/CD workflows.

Linux VPS
U
Loading...

Related Posts