setup java home java8 and mvn in yosemite

1. download and install java 8.

2. download and extract maven

3. create a .bash_profile under ~ (Users/yourname) if you do not have such a file (use ls -a to view all files including hidden ones). This file contains the options when you start your terminal.

4.  find your java_home first:

Java 7 and Java 8 are installed under /Library/Java/JavaVirtualMachines, and to get informations about the installed Java VM’s you can use the /usr/libexec/java_home command, which is a link/shortcut to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java_home.

Some of the command to use are:

/usr/libexec/java_home -verbose will give you all installed versions with path.

/usr/libexec/java_home -v '1.6*' will give you JAVA_HOME of Java 6

/usr/libexec/java_home -v '1.7*' will give you JAVA_HOME of Java 7 (if installed)

/usr/libexec/java_home -v '1.8*' will give you JAVA_HOME of Java 8 (if installed)

And if /usr/libexec/java_home is called without any parameters you should get the current enabled (newest) Java version. If you don’t get the newest Java version when /usr/libexec/java_home is called, you can try a restart of your Mac, so that the system reload its current load of the /usr/bin/java link/shortcut to /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java

5. add following lines to the .bash_profile

export JAVA_HOME=your_java_home_path

export M2_HOME=your_maven_path

export PATH=$PATH:$M2_HOME/bin

6. now run java -version and mvn –version to check the installation.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s