How to Install Maven on macOS

Maven is a widely-used build automation and project management tool primarily used for Java projects. It simplifies the building process, manages dependencies, and streamlines project development. If you’re a macOS user and need to install Maven for your Java development projects, you’re in the right place. This step-by-step guide will walk you through the process of installing Maven on your macOS system.


Using Homebrew is one of the simplest and most efficient ways to install Maven on macOS. If you don’t have Homebrew installed, you can do so by following these steps:

Open Terminal.

Install Homebrew by running the following command:

/bin/bash -c "$(curl -fsSL"

After Homebrew is installed, you can proceed to install Maven:

brew install maven

Wait for the installation to complete. Homebrew will download and set up Maven along with its dependencies.

To verify that Maven is installed, run the following command:

mvn -version

This should display the Maven version and other relevant information as below.

install mvn in mac

Now you have Maven installed on your macOS system, ready to use for your Java projects.

Install Maven Manually

If you prefer not to use Homebrew, you can install Maven manually by following these steps:

Visit the Apache Maven download page at to find the latest version of Maven.

Download the binary archive (.tar.gz file) for the desired Maven version to your macOS system.

Open Terminal and navigate to the directory where you downloaded the Maven archive. Use the cd command to change directories.

Extract the downloaded archive by running the following command, replacing apache-maven-x.y.z with the actual version you downloaded:

tar -xzvf apache-maven-x.y.z-bin.tar.gz

Once the extraction is complete, move the Maven directory to a location of your choice. You can use the following command to move it to your home directory:

mv apache-maven-x.y.z ~/apache-maven

Next, add Maven to your system’s PATH variable by editing the .bashrc or .zshrc file. Open the file using a text editor, such as nano or vim:

nano ~/.bashrc


nano ~/.zshrc

Add the following line at the end of the file, replacing x.y.z with your Maven version:

export PATH=~/apache-maven/apache-maven-x.y.z/bin:$PATH

Save the file and exit the text editor.

To apply the changes, either close and reopen the Terminal or run the following command:

source ~/.bashrc


source ~/.zshrc

Verify that Maven is installed and configured correctly by running:

mvn -version
  1. This should display the Maven version and other relevant information.

You’ve now successfully installed Maven manually on your macOS system.

Happy Coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment