
You may installed a Java Development Kit (JDK) already in your Mac OS X, but what do you do you if your currently installed JDK version is not compatible? Well, I personally had situations like that. More recently, I had to compile a Java project with JDK 1.7 because Google App Engine had a trouble running the project built in JDK 1.8. But my Mac OS X Yosemite already installed JDK 1.8 in my system. So, I had to downgrade the JDK to 1.7 to compile the project. Here is what I did.
Java 8 on OS X Yosemite I downloaded a recent copy of IntelliJ, only to discover when I went to open it, OS Yosemite indicated I had no version of Java installed, and that I’d need to install an old version. Follow the steps below to enable it for the browsers. Go to System preferences - Java. A new window will open. Go to security tab (4th from left). Tick the checkbox labeled 'Enable java content in the browser'. In Safari you have to allow Java plugin as well. Go to Preferences-Security. Enable Internet plugin.
Java 8 Download For Mac Os X Yosemite
- Open a Terminal window
- Type java -versionand Enter to check which version of Java you have as a default
- Download the appropriate JDK from Oracle website for Mac OS
- Once you installed the JDK, cd into /usr/libexec from your Terminal window
- Type the following command: ./java_home -V Make sure that you put the capital letter V and Enter
- You will see all installed versions of Java in your Mac OS X
- Now, open ~/.bash_profile with a text editor. For example, with VIM, you will type vim ~/.bash_profile
- Add the following command at the start:
export JAVA_HOME=$(/usr/libexec/java_home -v version_of_your_java)
Java For Mac Os X Yosemite

Replace the version_of_your_java with the JDK version you want to set. For example, JDK 1.7 will be 1.7.
Save the file (for VIM, it is x! in a Command mode) and start a new Terminal window. Type java -versionagain to see the default Java version changed!
Hope you found this useful and please leave me a feedback so I can hear what you think.