Hoarding programming problems for you!

Looking for good programming challenges?

Use the search below to find our solutions for selected questions!

Configure Maven 3.2 to use JDK v1.7 under Mac OS X 10.9

Sharing is caring!

In this article i describe how to configure Maven 3.2 to use JDK v1.7 under Mac OS X 10.9
Step 1: Download Maven
Go ahead and download the latest Maven version here. For this tutorial just download the binaries: apache-maven-3.2.1-bin.tar.gz.

Step 2: Install Maven
Once you have downloaded the zipped file extract it. There should be a folder called apache-maven-version (apache-maven-3.2.1 in my case) with contents looking something like this:
- apache-maven-3.2.1
--- bin
--- boot
--- conf
--- lib
--- LICENSE
--- NOTICE
--- README.txt

We will install Maven in ‘/usr/local/apache-maven’ So go ahead and navigate to your /usr/local/ directory. You can do this by either using the Terminal using

or just typing ‘command-shift-g’ in the Finder and then entering ‘/usr/local/’ in the input field.

Next create a new directory called ‘apache-maven’ in your /usr/local/ directory and move the
‘apache-maven-version’ folder into the newly created ‘apache-maven’ directory. So you will have
a directory structure like follows: /usr/local/apache-maven/apache-maven-3.2.1/

Open a new Terminal window and type in:

enter your password and edit your profile file to contain the following:

Hit ‘control-o’ and then enter to save and finally ‘control-x’ to exit the editor.

Step 3: Install Java v1.7
Go to the official Oracle website and download the latest version of Java SE Kit here.

Mount the .dmg file and double click the Install Package to install the latest version of Java(version 1.7.0_60 in my case).

Java will be installed under ‘/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home’ in Mac OS X 10.9 (Mavericks). You can find this out by typing

in your Terminal.

Step 4: Configure profile file
Finally we need to set the Java home directory. Again type in the following in the Terminal:

authenticate and then enter the following:

So our final .bash_profile file looks like so:

Again hit ‘control-o’ and then enter to save and finally ‘control-x’ to exit the editor.

Step 5: Verify that everything went smoothly
Run

to verify that Maven is correctly installed. You should see something like:

Similarly run

to verify that Java is correctly installed. You should see something like:

Thats it! Thanks