Skip to content

Instantly share code, notes, and snippets.

@fscm
Last active October 27, 2025 10:26
Show Gist options
  • Select an option

  • Save fscm/dbd544d166b81b258e9c07c158656e38 to your computer and use it in GitHub Desktop.

Select an option

Save fscm/dbd544d166b81b258e9c07c158656e38 to your computer and use it in GitHub Desktop.
[macOS] Install Apache Maven

[macOS] Install Apache Maven

Instructions on how to install Apache Maven on macOS.

Uninstall

First step should be to unsinstall any previous Apache Maven installation. This step can be skipped if no Apache Maven version was previously installed.

This will completelly remove any Apache Maven version previously installed. If you which to keep the user packages installed with mvn you should skip the last set of commands.

To uninstall any previous Apache Maven installations use the following command:

sudo rm -rf /usr/local/apache-maven

(these are your maven settings and installed java packages, don't delete this if you plan on re-installing Apache Maven)

rm -rf ~/{.m2,.mavenrc}

Install

Apache Maven can be obtained here. Copy the link for the version that you want to install from there.

Get the Apache Maven binary archive and extract it with the following commands:

sudo mkdir -p /usr/local/apache-maven
curl --silent --location --retry 3 "https://dlcdn.apache.org/maven/maven-3/3.9.11/binaries/apache-maven-3.9.11-bin.tar.gz" | sudo tar xz --no-same-owner --strip-components=1 -C /usr/local/apache-maven/

Configure

Add the following line to the .bash_profile file:

export MAVEN_HOME='/usr/local/apache-maven'
export PATH="${MAVEN_HOME}/bin:${PATH}"

Verify

Open a new terminal window and check if maven is installed:

mvn -v

Also check if the MAVEN_HOME environment variable was defined using the following command:

echo $MAVEN_HOME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment