In 2022, you can use just brew

brew install openjdk

and maybe you need to update PATH env:

export PATH="/usr/local/opt/openjdk/bin:$PATH"

…and for the future give a try to sdkman, is better than brew

curl -s "https://get.sdkman.io" | bash

then open a new shell and try list to see what you could install ;-)

sdk list java 

At time of writing you could use:

sdk install java 17.0.1-tem
Answer from freedev on Stack Overflow
🌐
Oracle
java.com › en › download › help › mac_install.html
How do I install Java for my Mac?
1. Download the jre-8u311-macosx-x64.dmg file. Review and agree to the terms of the license agreement before downloading the file. ... 4. Double-click on the .app icon to launch install Wizard. You might be prompted with message indicating app being downloaded from the Internet.
Top answer
1 of 2
9

To entirely use a (bash) shell to install e.g. Java 8u112 JRE do the following:

Download:

cd ~/Downloads
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u112-b15/jre-8u112-macosx-x64.dmg > jre-8u112-macosx-x64.dmg

Mount:

hdiutil attach jre-8u112-macosx-x64.dmg

Install:

sudo installer -pkg /Volumes/Java\ 8\ Update\ 112/Java\ 8\ Update\ 112.app/Contents/Resources/JavaAppletPlugin.pkg -target /

Clean-up:

diskutil umount /Volumes/Java\ 8\ Update\ 112 
rm jre-8u112-macosx-x64.dmg

To install the latest Oracle JDK (at the time of writing this answer it's Java 8u121 JDK) the various paths (besides the version number) are slightly different compared to the older JRE version. The URL contains an additional directory (i.e. /e9e7ea248e2c4826b92b3f075a80e441) and the dmg file contains a .pkg file instead of an installer app:

cd ~/Downloads
curl -v -j -k -L -H "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u121-b13/e9e7ea248e2c4826b92b3f075a80e441/jdk-8u121-macosx-x64.dmg > jdk-8u121-macosx-x64.dmg
hdiutil attach jdk-8u121-macosx-x64.dmg
sudo installer -pkg /Volumes/JDK\ 8\ Update\ 121/JDK\ 8\ Update\ 121.pkg -target /
diskutil umount /Volumes/JDK\ 8\ Update\ 121
rm jdk-8u121-macosx-x64.dmg
2 of 2
25

The best/safest way to install Java on macOS is with Homebrew; just type this:

brew install oracle-jdk --cask

Or if you don’t have Homebrew installed already, just type this command first:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install oracle-jdk --cask
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-on-mac
How to Install Java on Mac in 2026
February 20, 2026 - Here's my recommendation: Install Java 25 using Homebrew with the Eclipse Temurin distribution. Java 25 is the current LTS (Long-Term Support) release and your best choice unless your work team or university course uses an older version. With Homebrew, one terminal command accommodates the entire installation.
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-java-on-macos
How to Install Java on MacOS: A Step-by-Step JDK Installation - GeeksforGeeks
July 23, 2025 - Now we need to change the path of Java on Mac, for which certain steps are to be followed these steps : Step 1: Open Terminal -> type: “which java”. It should show something like /usr/bin/java.
🌐
Oracle
docs.oracle.com › javase › › 9 › install › installation-jdk-and-jre-macos.htm
8 Installation of the JDK and the JRE on macOS
Enter the following in a Terminal window (note the escaped space character, ignore line break): % /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java -version ... If you have not yet installed Apple's Java OS X 2012-006 update, then you are still using a version of Apple Java 6 that includes the plug-in and the Java Preferences application. See Notes for Users of macOS That Include the Apple Java 6 Plug-in.
🌐
Uakron
cs.uakron.edu › ~xiao › isp › JavaOnMacOS.html
Installing Java on MacOS
Go to this link to download Java JDK. You can download the latest version if you wish · Download the .dmg file that says 'macOS Installer' Once it is downloaded, open the .dmg file and follow the instructions. You usually just have to click continue and instsll then enter your password at the end.
🌐
Medium
tejaksha-k.medium.com › a-step-by-step-guide-to-installing-java-on-macos-5188bfdf99d7
A Step-by-Step Guide to Installing Java on macOS | by Tejaksha K | Medium
July 29, 2024 - This will mount the disk image, and you will see the JDK package inside. Install JDK: Double-click the JDK package icon to start the installation process. Follow the on-screen instructions to complete the installation.
Find elsewhere
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › install › mac_jdk.html
JDK 8 Installation for macOS
April 21, 2026 - This page describes how to install and uninstall JDK 8 for macOS computers.
🌐
TecAdmin
tecadmin.net › install-java-macos
How to Install JAVA on macOS – TecAdmin
April 26, 2025 - Ao login to your Mac system and open terminal · Homebrew: This tutorial relies on Homebrew, So you must have homebrew installed. Homebrew can be installed with a single command. You can follow these instructions to install Homebrew · The Homebrew contains the latest stable java version along with the LTS release Java 8, 11 LTS, and Java 17.
🌐
MacPaw
macpaw.com › how to › optimization › apps
How to install Java on your Mac
August 19, 2025 - Wait for the installer to finish, then click Close. To confirm the installation was successful, go to Applications > Utilities and open Terminal. Then type java -version and press Return.
🌐
Mkyong
mkyong.com › home › java › how to install java jdk on macos
How to install Java JDK on macOS - Mkyong.com
January 19, 2021 - This article shows how to install Java JDK on macOS, Homebrew package manager, manual installation, and switch between different JDK versions. ... 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).
🌐
Snyk
snyk.io › blog › install-java-on-macos
How to install Java on macOS | Snyk
April 17, 2024 - The first step is to check if Java is already installed on your system. macOS comes with Java installed by default, but it might not be the version you need for your specific use case. To check if Java is installed, open your Terminal application (You can use Spotlight search and type `Terminal`), ...
🌐
Oracle
java.com › en › download › help › java_mac.html
Installing and using Oracle Java on macOS
Information about Oracle Java for Mac - Install, remove, revert Apple Java 6, configure, system requirements
Top answer
1 of 3
1

I tested this answer using a clean install of High Sierra 10.13.6. All updates from Apple were installed.

The downloads of the JDKs can be found at Java Downloads. I could not correctly view this site using Safari under High Sierra. Instead, I installed and used Firefox ESR (Extend Support Release). This link for Firefox download can be successfull viewed from Safari. The file I downloaded and installed was Firefox 115.16.1esr.dmg.

I tried JDK 23 by downloading and installing jdk-23_macos-x64_bin.dmg. This was not recognized by Java. Next, I tried JDK 21 by downloading and installing jdk-21_macos-x64_bin.dmg. This was recognized by Java.

Instructions for uninstalling a JDK can be found here. Personally, I just used the Finder to move the /Library/Java/JavaVirtualMachines/jdk-23.jdk folder to the Trash.

I tested by using the simple code given below. The code was stored in the file named Simple.java.

class Simple{  
    public static void main(String args[]){  
     System.out.println("Hello Java");  
    }  
}

Example of testing is given below.

dmas-Mac:Desktop dma$ javac Simple.java 
dmas-Mac:Desktop dma$ java Simple
Hello Java

BTW, I tested JDK 23 using macOS Monterey and did not encounter the problems that occurred with High Sierra.

2 of 3
0

I've successfully installed Java 21 from Microsoft on High Sierra.

$ java --version
openjdk 21.0.8 2025-07-15 LTS
OpenJDK Runtime Environment Microsoft-11933195 (build 21.0.8+9-LTS)
OpenJDK 64-Bit Server VM Microsoft-11933195 (build 21.0.8+9-LTS, mixed mode, sharing)

Java 25 has the some issue as mentioned above. It looks like the jdks have been build with a dependency to "chkstk_darwin" which ist not available in High Sierra.

🌐
PhoenixNAP
phoenixnap.com › home › kb › devops and development › how to install java on mac
How to Install Java on Mac | phoenixNAP KB
May 8, 2025 - Intel-based Mac owners should choose the x64 installer. 3. Open the downloaded DMG file and run the PKG file inside. 4. Select Continue on the installer's introductory screen. 5. Select Install in the window that appears. 6. Provide your administrative credentials to start the JDK installation. 7. Wait for the installer to finish copying the files, then select Close. 8. Confirm JDK was installed successfully by running java -version in the terminal: java -version ·
🌐
Oracle
docs.oracle.com › en › java › javase › 22 › install › installation-jdk-macos.html
4 Installation of the JDK on macOS
March 14, 2024 - Previous Next JavaScript must be enabled to correctly display this content ... The JDK supports both Intel-based (x64) and Apple Silicon (AArch64) Mac computers. ... For supported processors and browsers, see Oracle JDK Certified Systems Configurations. JDK installers now support only one version of any Java feature release.
🌐
Mac Install Guide
mac.install.guide › java › install
Install Java on Mac · Mac Install Guide · 2026
Existing Terminal windows may not detect the new installation. ... $ java -version openjdk version "25.0.1" 2025-10-21 LTS OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8-LTS) OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8-LTS, mixed mode) The output confirms three things: the version number (25.0.1), the distribution (Temurin), and that the 64-Bit Server VM is active. ... $ /usr/libexec/java_home -V Matching Java Virtual Machines (1): 25.0.1 (arm64) "Eclipse Adoptium" - "OpenJDK 25.0.1" /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
🌐
Opensource.com
opensource.com › article › 20 › 7 › install-java-mac
How to install Java on a Mac | Opensource.com
(If you are running Linux, please see Seth Kenlon's article How to install Java on Linux.) Homebrew is the de-facto standard package manager for macOS.