How to Setup maven on Mac OS X

Let us see how to setup maven project : "A Project Object Model (POM) based management, build, reporting and documentation tool" on Mac Operating system.


Operating System: Mac OS X Yosemite 10.10

Maven version: v3.3.3

Java version: Java Development Kit JDK 7 or higher

Disk requirement: min 10Mb

You can download the latest build from Apache Maven website :

Note : If you are using older version of Mac OS X (1.6) you may find maven installed under /usr/share/maven.

Setting up maven:

Download maven Binary tar.gz archive ( latest :

Go to terminal app

Execute the following commands to set Java and Maven bin path :

export PATH=/Users/username/Setups/apache-maven-3.3.3/bin:$PATH JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/

To check if maven is configured correctly run the following command: mvn -version

localhost:Users username$ mvn -version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T17:27:37+05:30)
Maven home: /Users/username/Setups/apache-maven-3.3.3
Java version: 1.8.0_25, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8
OS name: "mac os x", version: "10.10.3", arch: "x86_64", family: "mac"

localhost:Users username$

Note : If the path is not set correctly you may get errors when you run mvn - version

localhost:Users username$ export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/
localhost:Users username$ mvn -version
Error: JAVA_HOME is not defined correctly.
We cannot execute /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Hom//bin/java
localhost:Users username$

Note: Maven 3.3.3 requires java version 1.7 or above, if you use a version below it you may get the following error,

localhost:Users username$  mvn --version

Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/maven/cli/MavenCli : Unsupported major.minor version 51.0
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClassCond(
	at java.lang.ClassLoader.defineClass(
	at Method)
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(
	at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
	at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(
	at org.codehaus.plexus.classworlds.launcher.Launcher.getMainClass(
	at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(
	at org.codehaus.plexus.classworlds.launcher.Launcher.launch(
	at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(
	at org.codehaus.plexus.classworlds.launcher.Launcher.main(

localhost:Users username$