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
mvn: command not found
- Recheck
M2_HOMEpath. - Confirm
PATHline is exactly added. - Run
source ~/.zshrcagain.
- Wrong Maven version appears
- Run
which mvnto see the active Maven binary. - Remove conflicting older Maven entries from your PATH.
- 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:
- Verify Java
- Download Maven
- Extract and move it
- Set
M2_HOMEandPATH - Verify with
mvn -v
Once this is set, you can build Java projects consistently from the terminal and IDE.