Back to Blog

How to Install Maven on Mac Manually (Step by Step)

If you want full control over your Java build setup, installing Maven manually on macOS is a clean and reliable option.

This guide follows a straightforward process from prerequisite checks to final verification.

Prerequisite

Verify Java is installed:

java -version

Maven requires JDK 8 or higher.

Step 1: Download Maven

Download the latest binary archive from the official Apache Maven website.

Example file:

apache-maven-3.x.x-bin.tar.gz

Step 2: Extract Maven archive

Open Terminal and move to Downloads:

cd ~/Downloads

Extract the archive:

tar -xvf apache-maven-3.x.x-bin.tar.gz

Step 3: Move Maven to a permanent location

Move extracted Maven folder to /usr/local:

sudo mv apache-maven-3.x.x /usr/local/apache-maven

This gives you a stable install path.

Step 4: Configure environment variables

Open your shell config file:

  • Zsh: ~/.zshrc
  • Bash: ~/.bash_profile

For Zsh:

nano ~/.zshrc

Add these lines:

export M2_HOME=/usr/local/apache-maven
export PATH=$M2_HOME/bin:$PATH

Save and exit (Ctrl+O, Enter, Ctrl+X).

Step 5: Apply changes and verify

Reload your shell profile:

source ~/.zshrc

Check Maven version:

mvn -v

If the command prints Maven version details, your installation is complete.

Quick troubleshooting

  1. mvn: command not found
  • Recheck M2_HOME path.
  • Confirm PATH line is exactly added.
  • Run source ~/.zshrc again.
  1. Wrong Maven version appears
  • Run which mvn to see the active Maven binary.
  • Remove conflicting older Maven entries from your PATH.
  1. Java errors while running Maven
  • Verify Java is available with java -version.
  • Ensure a compatible JDK is installed.

Final takeaway

Manual Maven installation on macOS is just five parts:

  1. Verify Java
  2. Download Maven
  3. Extract and move it
  4. Set M2_HOME and PATH
  5. Verify with mvn -v

Once this is set, you can build Java projects consistently from the terminal and IDE.