1. Download apache-maven-3.5.0-bin.tar.gz from Apache maven website.
https://maven.apache.org/download.cgi
2. extract the above file in any directory in your machine(lets refer as: <directory_maven>)
$ cd <directory_maven>
$ ls
(should list all contents)
$ export M2_HOME=/Users/<your username>/<directory_name>/apache-maven-3.5.0
Ex(in my machine): /Users/sriramkukkadapu/Downloads/apache-maven-3.5.0
Note : above path can also be something like /usr/local. provide accordingly.
$ export M2=$M2_HOME/bin
3. This is a important step. JAVA_HOME should be configured properly.
To check the current JDK home. go to the root folder in ur user(just do cd.. multiple times).
Then go to /Library/Frameworks/JavaVM.framework/Versions/
here you will find current JDK version. Ex jdk1.8.0_144.jdk (in my machine)
Now form the below path with your JDK Version Replaced.
/System/Library/Frameworks/JavaVM.framework/Versions/<Your JDK Version>/home
Ex(My machine) : /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/home
Now Set JAVA_HOME Variable.
$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/home
4. Setting Path Variable to Java_Home/bin.
$ export PATH=$M2:$JAVA_HOME/bin:$PATH
5. Done, Now check maven version
$ mvn –version
Hope it is useful :)
https://maven.apache.org/download.cgi
2. extract the above file in any directory in your machine(lets refer as: <directory_maven>)
$ cd <directory_maven>
$ ls
(should list all contents)
$ export M2_HOME=/Users/<your username>/<directory_name>/apache-maven-3.5.0
Ex(in my machine): /Users/sriramkukkadapu/Downloads/apache-maven-3.5.0
Note : above path can also be something like /usr/local. provide accordingly.
$ export M2=$M2_HOME/bin
3. This is a important step. JAVA_HOME should be configured properly.
To check the current JDK home. go to the root folder in ur user(just do cd.. multiple times).
Then go to /Library/Frameworks/JavaVM.framework/Versions/
here you will find current JDK version. Ex jdk1.8.0_144.jdk (in my machine)
Now form the below path with your JDK Version Replaced.
/System/Library/Frameworks/JavaVM.framework/Versions/<Your JDK Version>/home
Ex(My machine) : /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/home
Now Set JAVA_HOME Variable.
$ export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/home
4. Setting Path Variable to Java_Home/bin.
$ export PATH=$M2:$JAVA_HOME/bin:$PATH
5. Done, Now check maven version
$ mvn –version
Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T01:09:06+05:30)
Maven home: /Users/sriramkukkadapu/Downloads/apache-maven-3.5.0
Java version: 1.8.0_144, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.11.6", arch: "x86_64", family: "mac"
Hope it is useful :)