Step By Step: Installing Maven on Mac

Step By Step: Installing Maven on Mac

Apache Maven is a popular build automation and project management tool primarily used for Java projects. Here are the steps to install Maven on Mac OS:

Step 1 – Install Java

Since Maven is Java-based, the first step is to ensure Java is installed. Ideally, install the latest Java Development Kit (JDK) from Oracle’s website (https://www.oracle.com/uk/java/technologies/downloads/).

You can follow the step here for Installing Java on Mac: https://felixrante.com/step-by-step-installing-java-on-mac/

Step 2 – Download Maven Archive

Go to the official Maven website https://maven.apache.org/download.cgi and download the latest binary archive (apache-maven-*.zip).

Step 3 – Extract the Archive

Open your downloads folder and extract the downloaded maven archive. You can move this extracted folder to a suitable location like /opt/ folder.

$ sudo tar -xzf apache-maven-*.zip -C /opt/

Step 4 – Configure PATH

Add the Maven bin folder path to the system PATH. Open .bash_profile file and add the following at end:

export PATH=/opt/apache-maven-<version>/bin:$PATH

Step 5 – Verify the Installation

Open a new terminal and run the mvn command. You should see the Maven version and other details printed which confirms Maven is installed correctly.

$ mvn -v
Apache Maven <version>
Maven Installation

Step 6 – Set JAVA_HOME

Make sure JAVA_HOME environment variable is set to your JDK installation location.

export JAVA_HOME=/Library/Java/JavaVirtualMachines/<jdk_version>.jdk/Contents/Home

That’s it! Maven is now installed and ready to build your Java projects.

Next Steps

  • Create a sample Maven project
  • Learn how to configure pom.xml
  • Use commonly used Maven commands
  • Integrate Maven with CI/CD

Let me know if you have any other questions!

Leave a Reply

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


Translate ยป