天天看點

How to install Maven on Mac OS X Mavericks (10.9)

Step 1: Download Maven binaries from Maven Download Page. I was using Maven 3.0.5, so I downloaded apache-maven-3.0.5-bin.tar.gz.

Step 2: You can install Maven at any location but since it’s a one time process, I didn’t wanted it in my user directory. So I installed it in /usr/local directory. You might have to use sudo command to install in /usr/local directory if you are getting permission denied error.

$ cd /usr/local
$ sudo mv /Users/chang/Desktop/apache-maven--bin.tar.gz ./
$ sudo tar -xvf apache-maven--bin.tar.gz
           

Step 3: Now open the bash profile file and add following lines into it. Usually profile file names are .bash_profile or .profile, use whichever you have in your system. If you don’t have profile file, you will have to create one with vi command.

$ cd $HOME
$ vi .bash_profile
#Add below lines in the profile
export M2_HOME=/usr/local/apache-maven-.
export PATH=$PATH:$M2_HOME/bin
#save and quit
$ source .bash_profile 
           

That’s it, maven is installed on your latest Mac OS X and you can verify it by issuing below command.

$ mvn --version
Apache Maven  (a5524ec3e0dfe41d4a06; --T19::+:)
Maven home: /usr/local/apache-maven-
Java version: _71, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1_71.jdk/Contents/Home/jre
Default locale: zh_CN, platform encoding: UTF-
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"
           

參考:http://www.journaldev.com/2348/how-to-install-maven-on-mac-os-x-mavericks-10-9