How to Install Maven on macOS 2025

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.

Share:

More Posts

How to Use Google SMTP Server

What you will read?1 Step 1: Enable SMTP Access in Gmail2 Step 2: Secure Connection with TLS3 Step 3: Send an Email via SMTP4 Step

how to install wine on RHEL

What you will read?1 Check RHEL version and CPU architecture2 Update system and install base tools3 Verify subscription and enable CodeReady Builder4 Enable EPEL repository5

how to install wine on centos

What you will read?1 Check your CentOS version2 Update system packages3 Enable EPEL and core build repos4 Prepare 32-bit multilib support5 Install Wine packages6 Verify

Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments