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

Filed Under: Softwares

Recently I upgraded my Mac OS X to Mavericks (10.9) and I was surprised to see that it doesn’t come with Maven. Earlier versions of Mac OS X such as Lion and Mountain Lion used to have maven installed by default.

There are some third party options such as HomeBrew and using XCode to install Maven on Mac OS X Mavericks but I wanted to do it myself without relying on another software for getting maven working.

Here are the steps that I used to install maven on Mac OS X Mavericks.

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/pankaj/Downloads/apache-maven-3.0.5-bin.tar.gz ./
$ sudo tar -xvf apache-maven-3.0.5-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-3.0.5
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 3.0.5 (r01de14724cdef164cd33c7c8c2fe155faf9602da; 2013-02-19 05:51:28-0800)
Maven home: /usr/local/apache-maven-3.0.5
Java version: 1.7.0_09, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.9", arch: "x86_64", family: "mac"

You can use this method to install any maven version you would like to use and at your specified location.

Let me know if you find any issues with above setup steps.


  1. Xuan Trieu says:

    thank you so much, I tried it and worked, after going frustrated with “how to fix Maven downloaded via Homebrew”

  2. Jyoti says:


    I tried the steps. When I do this it works for single session. i.e. Next time when I close and reopen terminal and do man -version I get:
    -sh: mvn: command not found

    How to fix this?
    Waiting for reply

  3. iliyaz says:

    Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

    1. freejack says:

      I got the same Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

  4. Helen says:

    Thanks a bunch! This worked 100%.

  5. Tarun says:

    Helped alot! Thanks

  6. rogerhuang says:

    Thanks for that

  7. Arun says:

    Thanks for that

  8. bikshapathi says:

    Thanks for the article.

  9. Igor says:

    Thanks a lot for this manual. Much appreciated)

  10. Priya says:

    I am not able to locate the .m2 folder. I installed the entire thing in my Documents folder. Also, I have enabled all hidden files to be shown. Yet, I can’t see the .m2 where my local repo will be.

    Please help!

    1. Pankaj says:

      By default it’s located in the user home directory.

  11. Brian says:

    May I recommend creating a symbolic link for maven once you have it installed rather than having the specific version in your path and M2_Home variable?

    ln -s apache-maven-3.0.5 maven

    That way you only have to move the symbolic link when you install a new version.

    1. Pankaj says:

      Its a personal choice, I prefer to have these kind of settings in my bash profile. I have java 6, 7, 8 setup and java home is configured in bash profile.

  12. Sang Min Park says:

    thank you so much. 🙂

  13. Gibran Castillo says:

    Excellent tutorial. Simple and to the point

  14. A_V says:

    Very precise and easy tutorial. Thank You.
    The way to open a .bash_profile

    touch .bash_profile

    then say:

    open -a .bash_profile

  15. Silvio Di Pasquale says:

    Thank you so much for the wonderful tutorial!

  16. Afreen says:

    Thank you for the wonderful tutorial! (y)

  17. alex says:

    I would recommend using homebrew ( and simply do:

    brew install maven

  18. flybrid says:

    I got the error below

    Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher

    1. flybrid says:

      I resolved it myself.

      1. Fijai Cairo says:

        How did you resolve it?

        1. Fijai Cairo says:

          export M2_HOME=/usr/local/Cellar/maven/3.2.2/libexec

        2. Wiem SGHAIER says:

          export M2_HOME=/usr/local/apache-maven/apache-maven-3.2.5
          export M2=$M2_HOME/bin
          export PATH=$M2:$PATH

  19. James says:

    Thanks for that!

  20. cindy says:

    thanks! this instructions helped me a lot!

Leave a Reply

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

Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages