How to Setup Maven on Mac

Hello Friends,

In this post,we will learn how to setup maven on Mac machine.





I am using :

Mac OS Version 10.11.6
Maven 3.3.9
JDK : 1.8 (minimum 1.7 version required with maven 3.3.9)


Step 1 :

Go to Apache Maven's official web site http://maven.apache.org/download.cgi

Step 2:

Download maven at any convenient location on your system from following link.It comes in compact form in tar.gz format.

https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/

Step 3:

Extract by executing following command

tar -xvf apache-maven-3.3.9-bin.tar.gz

Step 4:

Open terminal utility and execute following command :

vim ~/.bash_profile

Step 5 :

Press 'I'  key,which will bring .bash_profile in edit  mode.

Step 6 :

Set environment variable M2_HOME as location of maven folder you extracted in  step 3,by adding following line in .bash_profile file  :

export M2_HOME = /Users/Aakarsh/Downloads/apache-maven-3.53.9

Step 7 :

Set PATH environment variable as below by adding following line in .bash_profile file,so that you can execute maven commands from any directory.

export PATH = $PATH:$M2_HOME/bin


Step 8 :

Set environment variable JAVA_HOME as location of JDK on your system.If you don't have JDK installed ,you should install that first.

Here is the path where you can find jdk installed :
/Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home

export JAVA_HOME = /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home


Step 9: To know if maven is installed successfully,execute following command and you will be able to see installed version.

mvn -version




Step 10: To know the location of maven ,execute following command

which mvn 



Thats it.So with this we learnt that how to set up maven on mac machine.

Thanks for reading.Let me know if you face any issue in setting up in comments section.