In the past Oracle didn't support MacOS X, however as of JDK 7 update 6 this is no longer the case. When I run the JDK auto installer against an OSX machine I am getting 'JDK installation skipped: Unknown CPU name: mac os x'. Expected behavior: Add support for auto-installing Oracle's JDK on MacOS X. Do not install either JDK 9 or JDK 10, as they are currently incompatible with DrJava. Browse to Java SE Development Kit 8u171. In the first table, check Accept License Agreement and the click jdk-8u171-macosx-x64.dmg, which corresponds to the entry for Mac OS X. The exact verison 8u171 is not essential.
This article shows how to install Java JDK on macOS, Homebrew package manager, manual installation, and switch between different JDK versions.
Tested with
- macOS 11 Big Sur
- Homebrew 2.7.4
- JDK 8, 14, 16, 16 (AdoptOpenJDK and OpenJDK)
Java SE 9.0.4 The Java Platform lets you develop and deploy Java applications on desktops and servers, as well as in today's demanding embedded environments. In this example, it is called bellsoft-jdk8u252+9-macos-amd64-full-nosign.zip. We use a special unsigned Liberica JDK 8u252 because the javapackager cannot re-sign already signed JDK files. Extract the unsigned Liberica JDK 8u252 bundle. The good news is that Zulu 9 will work quite happily on Windows 7 (and later versions) in both 32 and 64-bit variations. If you need Windows or Linux 32-bit (or Mac OS X) versions of JDK 9 (and soon JDK 10) you can find them on our website.
Topics
P.S At the time of writing, the latest JDK GA is JDK 15, and the early access build is JDK 16.
Note
Since macOS 10.15 Catalina, the default Terminal shell switch from the bash (Bourne-again shell) to zsh (Z shell). And we should move all the startup scripts and environment variables in ~/.bash_profile or ~/.bashrc to ~/.zshenv or ~/.zshrc.
Also, read this Zsh Startup Files.
1. Homebrew install latest Java on macOS
1.1 Install and upgrade Homebrew.

1.2 brew search java to find all available Java-related formula.
1.3 brew info to show the formula details.
The java formula is always containing the latest Java JDK (OpenJDK) GA version; at the time of writing, the latest GA is JDK 15.
The java11 formula is containing the Java 11 LTS version.
1.4 brew install java to install the latest JDK 15.
1.5 Where does Homebrew install the java?
Homebrew installed the JDK files and directories at /usr/local/Cellar/openjdk/, and symbolic link at /usr/local/opt/openjdk points to the latest Java 15.0.1 version.
1.6 The java formula is keg-only, which means it is installed in /usr/local/Cellar but not linked into places like /usr/local/bin or /Library/Java/JavaVirtualMachines/ (macOS /usr/bin/java wrapper).
For macOS /usr/bin/java wrapper to find the installed JDK, we manually create a symbolic link at /Library/Java/JavaVirtualMachines/.
1.7 Done.
2. Homebrew install Java 8 on macOS
2.1 Install and upgrade Homebrew.
2.2 The brew search java has no java8?

2.3 The Java 8 is available at the openjdk@8 formula. The openjdk is the same as the java formula, and it always contains the latest JDK GA version; the openjdk@11 is the same as the java11 formula, containing JDK 11.
2.4 We can use the openjdk@8 formula to install Java 8 on macOS.
2.5 The openjdk@8 is also a keg-only; we need to create a symbolic link so that the macOS java wrapper can find it.
2.6 Done.
2.7 What if we have multiple Java versions installed?
We can update the $PATH at ~/.zshrc, so that the macOS can find the correct installed Java.
$JAVA_HOME
Alternatively, we can set the $JAVA_HOME environment variable on macOS.
3. Homebrew install a specified Java (AdoptOpenJDK) on macOS.
The adoptopenjdk/openjdk tap containing a lot of different JDK (AdoptOpenJDK) versions.
3.1 Add a new tap (third party repository) adoptopenjdk/openjdk.
3.2 Search related adoptopenjdk formula.
3.3 We pick adoptopenjdk14 formula to install the JDK 14.
3.4 The adoptopenjdk formula creates the JDK home directly in the /Library/Java/JavaVirtualMachines/.
3.5 Since the JDK home is already in /Library/Java/JavaVirtualMachines/, we do not need to create any symbolic link, just export $PATH and point it to the correct adoptopenjdk-14.jdk.
Note
Also read this Switch adoptopenjdk cask to use pkg #73145
4. Manual install Java (Early-Access Builds) on macOS.
For some reasons, we need to install Java on macOS manually:
- Anti-Homebrew, developers love to control everything.
- The JDK build doesn’t exist in the Homebrew repository, like the early-access builds, or Oracle JDK.
P.S At the time of writing, the JDK early-access build is JDK 16.
Download Jdk 9 For Mac

4.1 Access the JDK 16 early access build website and download the JDK.
4.2 Extracts the downloaded tar.gz file to /Library/Java/JavaVirtualMachines
4.3 Update $PATH and point to the /Library/Java/JavaVirtualMachines/jdk-16.jdk
4.4 Test JDK 16.
Done. Perfect keylogger mac.
5. Switch between different JDK versions
From the above example 1 to example 4, we have installed four JDK versions on macOS.

5.1 List all the JDK versions on macOS.
5.2 Add the below function in the ~/.zshrc (for macOS 10.15 Catalina, and above) or ~/.bashrc (before macOS 10.15 Catalina).
Jdk 9 Install Mac
P.S Create the file ~/.zshrc if it doesn’t exists.
5.3 Source the ~/.zshrc to reflect the changes.
5.4 Switch between different JDK versions.
Further Reading
How to set $JAVA_HOME environment variable on macOS. Unibeast without dmg from custom iso mac download.