Upgrading Maven on Mac OS X is generally nothing very special, but I’d like to summarize the steps I’ve done. Maybe it is helpful for users which are not so familiar with the Terminal application.
- First of all: start the Terminal application, located in the folder
- Here you can find out which Maven version is currently running, by typing
mvn -version. You will get some output starting with the Maven version number, such as:
Apache Maven 2.0.9. The latest version of Maven is 2.2.1 by the time of writing this article, so you see there is the need to upgrade.
- Now you have to locate the
mvncommand in your file system. Type
whereis mvn. The output will be the complete path of the executable:
- This is most likely not the place where Maven is installed, but a symbolic link to the Maven executable of your system. To find out where this link refers to, type
(replace the path with your own
mvnlocation). The output will look like this:
lrwxr-xr-x 1 root wheel 37 2 Sep 22:39 /usr/bin/mvn -> /usr/local/apache-maven-2.0.9/bin/mvn
- Now change to the parent directory of the Maven installation.
- Open Safari and download Maven from the Maven Homepage. Instead of downloading with Safari, you can also use a command line tool. Please use the mirror which is best for you:
- Now extract the archive:
tar -xzvf apache-maven-2.2.1-bin.tar.gz
- Optional: move the extracted archive to the right folder:
sudo mv apache-maven-2.2.1 /usr/local
- Now link the Maven command to the new version: sudo ln -fs /usr/local/apache-maven-2.2.1/bin/mvn /usr/bin/mvn
That’s it. Now you can try if the latest version is actually installed. Type
mvn -version again, and you will see:
If you are not able to execute the
mvn command, it is possible that the execute flag is missing. Change this by typing
chmod a+x /usr/local/apache-maven-2.2.1/bin/mvn