If you would like to learn Java programming, the best way is by writing Java codes by yourself. To compile the Java codes then you need Java Development Kit (JDK). It can be Oracle JDK or OpenJDK. This post guides you how to install Oracle JDK 8 on Mac OS X 10.10 Yosemite. It should be also applicable for previous version of OS X such as OS X Maverick, Mountain Lion, and OS X Lion. At the time of this post written, the latest version of JDK is JDK 8 Update 25.
Basically I previously had written an article how to install Java SE 7 / JDK 7 on Mac OS X Lion. I just would like to rewrite on the newest version.
1. Download Oracle JDK 8 from Oracle website. You need to accept license agreement to be able to download the file. Make sure you select the Mac OS X x64 platform (jdk-8u25-macosx-x64.dmg).
2. Double-click the downloaded file ‘jdk-8u25-macosx-x64.dmg’ and follow the on-screen installation.
3. Once it is successfully installed, it is installed inside /Library/Java/JavaVirtualMachinesfolder.
$ ls -l /Library/Java/JavaVirtualMachines/ total 0 drwxr-xr-x 3 root wheel 102 Nov 4 2013 jdk1.7.0_45.jdk drwxr-xr-x 3 root wheel 102 Jan 16 14:13 jdk1.8.0_25.jdk
4. Verify that the system is now using JDK 8.
$ java -version java version "1.8.0_25" Java(TM) SE Runtime Environment (build 1.8.0_25-b17) Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
5. If you would like to uninstall JDK 8, simply remove the jdk1.8.0_25.jdk
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/
Hopefully this tutorial helps you on installing JDK 8 / Java SE 8 on Mac OS X 10.10 Yosemite.