Java:multiple-versions-on-mac
Install multiple JDK Uninstall jdk8, install jdk7, then reinstall jdk8.
To switch between them, add the following to .profile
export JAVA_8_HOME=$(/usr/libexec/java_home -v1.8)
export JAVA_7_HOME=$(/usr/libexec/java_home -v1.7)
alias java7='export JAVA_HOME=$JAVA_7_HOME'
alias java8='export JAVA_HOME=$JAVA_8_HOME'
#default java8
export JAVA_HOME=$JAVA_8_HOME
Use homebrew-cask to install the versions of java, and use jenv to manage the installed versions of java
As seen on http://hanxue-it.blogspot.ch/2014/05/installing-java-8-managing-multiple.html, these are the steps to follow.
Repeat steps 4 to 6 for each version of java you need
Add the "caskroom/versions" tap to homebrew using:
brew tap caskroom/versions
Then you can look at all the versions available:
brew cask search java
Then you can install the version(s) you like:
brew cask install java7
brew cask install java6
And add them to be managed by jenv as usual.
jenv add <javaVersionPathHere>
I think this is the cleanest & simplest way to go about it.
For different types of JDKs or installations, you will have different paths
On Mac OS X Mavericks, I found as following:
Built-in JRE default: /Library/Internet/Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
JDKs downloaded from Apple: /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/
JDKs downloaded from Oracle: /Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home
Resources