Installing Maven on Mac OS X

Let us look at the steps to install Maven on Mac OS X. This applies to the latest version of Mac OS X, namely Yosemite.

Earlier, Apple provided Java for Mac, but stopped doing so from Java 7 onwards. Apple Java is not available on recent versions of Mac OS X.

Getting ready

Let us check if the Java environment is available on your Mac:

  1. Open the terminal and run the following command:
    /usr/libexec/java_home -v 1.7
    
  2. See if you get an output similar to the following:
    /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
    
  3. Run the following command to check if you have Java 8:
    /usr/libexec/java_home -v 1.8
    
  4. This should give the following output if Java exists:
    /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home ...

Get Apache Maven Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.