Upgrading Maven on Mac OS X

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.


  1. First of all: start the Terminal application, located in the folder /Applications/Utilities/Terminal.app.
  2. 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.
  3. Now you have to locate the mvn command in your file system. Type whereis mvn. The output will be the complete path of the executable: /usr/bin/mvn.
  4. 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 ln -sls -l /usr/bin/mvn (replace the path with your own mvn location). 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
  5. Now change to the parent directory of the Maven installation. cd /usr/local
  6. 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: http://apache.linux-mirror.org/maven/binaries/apache-maven-2.2.1-bin.tar.gz
  7. Now extract the archive: tar -xzvf apache-maven-2.2.1-bin.tar.gz
  8. Optional: move the extracted archive to the right folder: sudo mv apache-maven-2.2.1 /usr/local
  9. 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:

Maven Version Output

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

8 thoughts on “Upgrading Maven on Mac OS X”

  1. In 4. the right command is
    ls -l /usr/bin/mvn

    If you just want to know the target of a symlink
    readlink /usr/bin/mvn
    is also a suitably command.

  2. An arguably simpler way is to:
    1) extract
    2) set MAVEN_HOME
    3) set your path to be $MAVEN_HOME\bin:$PATH;

    That way it will find your new maven before the default one.

  3. Haikal, you’re right. But assuming you haven’t set MAVEN_HOME yet, you can do the steps described in this post.

Leave a Reply

Your email address will not be published. Required fields are marked *

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four 
    spaces will be stripped off, but all other whitespace
    will be preserved.
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax