How to install Maven on Mac OS - Maven Tutorial



Method 1: Alternatively, I recommend installing Homebrew for these kinds of utilities.

Then you just install Maven using:

brew install maven

PS: If you got a 404 error, try doing a brew update just before

Method 2:  OS X prior to Mavericks (10.9) actually comes with Maven 3 built in.

Now, you won’t have maven installed by default.

Step 1: Download Maven:  Download the Maven

For example, apache-maven-3.6.0-bin.tar.gz.

Extracts it,

tar -xvf apache-maven-3.6.0-bin.tar.gz$pwd/Users/admin/Downloads/apache-maven-3.6.0

Step 2: Set Maven command in the global environment variable: Update ~/. bash_profile

2.1 Create this file if it doesn’t exist.

$ vim ~/.bash_profile

2.2 ~/.bash_profile

export M2_HOME=/Users/admin/Downloads/apache-maven-3.6.0export PATH=$PATH:$M2_HOME/bin

 

Step 3: Restart the terminal. Test it.

$mvn -versionApache Maven 3.6.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T01:09:06+05:30)Maven home: /Users/admin/Downloads/apache-maven-3.6.0Java version: 9.0.1, vendor: Oracle CorporationJava home: /Library/Java/JavaVirtualMachines/jdk-9.0.1.jdk/Contents/HomeDefault locale: en_IN, platform encoding: UTF-8OS name: "mac os x", version: "10.13.3", arch: "x86_64", family: "mac"