
Installing JDK on macOS
Note that JDK requires a recent version of macOS. At the time of writing this, JDK 8 requires at least version 10.8 (Mountain Lion).
The installation of macOS is quite straightforward. Simply double-click on the downloaded image (the .dmg file), and in the Finder window that appears, double-click on the package icon. Follow the prompts. Like the Windows version, the macOS version is installed on a system-level basis and is therefore available to all users.
After the installation, you need to ensure the new JDK is the default one. macOS supports the installation of multiple JDK versions at the same time, and you can always switch to any one of them; however, only one version will be active at a time. The easiest way to do this is to open the .bash_profile file (note that the filename starts with a dot) in your user's Home folder and add the following line to it:
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"
To validate the installation:
- Open a new Terminal window
- Type javac -version and press Enter
You should see the version number that matches the downloaded JDK version.