Turns out java has been moved into brew core recently, so the correct command as of August 2022 is:

brew install java

Then check your installation by running

java -version

If the result does not looks like this:

openjdk 18.0.2 2022-07-19
OpenJDK Runtime Environment Homebrew (build 18.0.2+0)
OpenJDK 64-Bit Server VM Homebrew (build 18.0.2+0, mixed mode, sharing)

but like this:

The operation couldn’t be completed. Unable to locate a Java Runtime.
Please visit http://www.java.com for information on installing Java.

Then you also need to create a symlink for the system Java wrappers to find this JDK:

sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \
     /Library/Java/JavaVirtualMachines/openjdk.jdk
Answer from Tim Fulmer on Stack Overflow
🌐
Homebrew
formulae.brew.sh › formula › openjdk@21
Homebrew Formulae: openjdk@21
brew install openjdk@21 · Development kit for the Java programming language · https://openjdk.org/ License: GPL-2.0-only WITH Classpath-exception-2.0 · Development: Pull requests · Formula JSON API: /api/formula/openjdk@21.json · Formula ...
Discussions

where can i download java 21?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
16
3
June 23, 2024
Unable to install Java 8 on MBP M4
Use brew.sh Also Java 8 is… extremely old More on reddit.com
🌐 r/mac
15
2
January 13, 2025
downloading java
Google brew install openjdk. It’ll make installing Java and be able to run things easier as it will set up your terminal to point to the JVM More on reddit.com
🌐 r/learnprogramming
4
1
August 2, 2024
Which Java (JDK 21) Is Most Preferred for MacBook Air?
Please ensure that: Your code is properly formatted as code block - see the sidebar (About on mobile) for instructions You include any and all error messages in full You ask clear questions You demonstrate effort in solving your question/problem - plain posting your assignments is forbidden (and such posts will be removed) as is asking for or giving solutions. Trying to solve problems on your own is a very important skill. Also, see Learn to help yourself in the sidebar If any of the above points is not met, your post can and will be removed without further warning. Code is to be formatted as code block (old reddit: empty line before the code, each code line indented by 4 spaces, new reddit: https://i.imgur.com/EJ7tqek.png ) or linked via an external code hoster, like pastebin.com, github gist, github, bitbucket, gitlab, etc. Please, do not use triple backticks (```) as they will only render properly on new reddit, not on old reddit. Code blocks look like this: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } } You do not need to repost unless your post has been removed by a moderator. Just use the edit function of reddit to make sure your post complies with the above. If your post has remained in violation of these rules for a prolonged period of time (at least an hour), a moderator may remove it at their discretion. In this case, they will comment with an explanation on why it has been removed, and you will be required to resubmit the entire post following the proper procedures. To potential helpers Please, do not help if any of the above points are not met, rather report the post. We are trying to improve the quality of posts here. In helping people who can't be bothered to comply with the above points, you are doing the community a disservice. I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns. More on reddit.com
🌐 r/javahelp
8
2
January 17, 2024
🌐
Medium
medium.com › neural-engineer › installing-the-jdk-on-macos-2025-with-homebrew-temurin-and-openjdk-708f66701cdc
Installing the JDK on macOS (2025) with Homebrew, Temurin, and OpenJDK | by PI | Neural Engineer
December 1, 2025 - brew install openjdk · Some Homebrew JDKs need a manual macOS symlink so tools can find them: sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk.jdk · For Temurin casks that skipped creating a JVM entry: sudo ln -sfn /Library/Java/JavaVirtualMachines/temurin-*/Contents/Home \ /Library/Java/JavaVirtualMachines/temurin.jdk · java -version · You should see something like: openjdk version "21.0.1" 2025-01-01 LTS ·
🌐
Homebrew
formulae.brew.sh › formula › openjdk
Homebrew Formulae: openjdk
brew install openjdk · Also known as: java, openjdk@26 · Development kit for the Java programming language · https://openjdk.org/ License: GPL-2.0-only WITH Classpath-exception-2.0 · Development: Pull requests · Formula JSON API: /api/formula/openjdk.json ·
🌐
Mac Install Guide
mac.install.guide › java › java-21
Install Java 21 on Mac · Mac Install Guide · 2026
How to install Java 21 on Mac step by step. Get the free Java 21 JDK for macOS, install with Homebrew or a PKG, verify the version, and set JAVA_HOME.
🌐
Besu-eth
docs.besu-eth.org › how to › install and update java
Install and update Java | Besu documentation
1 month ago - If you started with this guide, ... the JDK version (for example, from 21 to 25), uninstall the old version and reinstall the target version: brew uninstall openjdk@21 ·...
🌐
Oracle
docs.oracle.com › en › java › javase › 21 › install › installation-jdk-macos.html
Installation of the JDK on macOS
July 15, 2025 - For example, JDK 21.0.1 is installed in /Library/Java/JavaVirtualMachines/jdk-21.jdk.
Find elsewhere
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.

🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@21
Homebrew Formulae: oracle-jdk@21
brew install --cask oracle-jdk@21 · Name: Oracle Java Standard Edition Development Kit · JDK from Oracle · https://www.oracle.com/java/technologies/downloads/ Development: Pull requests · Cask JSON API: /api/cask/oracle-jdk@21.json · Cask ...
🌐
Homebrew
formulae.brew.sh › cask › zulu@21
Homebrew Formulae: zulu@21
brew install --cask zulu@21 · Name: Azul Zulu Java Standard Edition Development Kit · OpenJDK distribution from Azul · https://www.azul.com/downloads/ Development: Pull requests · Cask JSON API: /api/cask/zulu@21.json · Cask code: zulu@21.rb ...
🌐
Mr N
bigsoft.co.uk › blog › 2025 › 11 › 07 › installing-all-the-javas-on-a-mac-and-switching-between-them
Installing all the Javas on a Mac and switching between them
November 7, 2025 - brew install openjdk@8 brew install openjdk@11 brew install openjdk@17 brew install openjdk@21 brew install openjdk@25 ... After the install has completed add this to your ~/.bash_profile and restart the shell. export PATH="$HOME/.jenv/bin:$PATH" eval "$(jenv init -)" If you'd like JAVA_HOME ...
🌐
Oracle
oracle.com › de › java › technologies › downloads
Java Downloads | Oracle Deutschland
Subsequent JDK 25 updates will be licensed under the Java SE OTN License (OTN) and production use beyond the limited free grants of the OTN license will require a fee. ... JDK 21 binaries are free to use in production and free to redistribute, at no cost, under the Oracle No-Fee Terms and Conditions (NFTC).
🌐
Adoptium
adoptium.net › temurin › releases
Temurin jdk-21.0.11+10, macOS aarch64 (M1) (.PKG)
All VersionsJDK 25 - LTSJDK 21 - LTSJDK 17 - LTSJDK 11 - LTSJDK 8 - LTS · No releases match your current filter criteria. Try adjusting your selections or reset all filters to see available releases. There are multiple different ways to get Eclipse Temurin beyond direct downloads. The curated list below shows some of these options for installing high-performance, cross-platform, open-source OpenJDK runtime binaries.
🌐
The-main-thread
the-main-thread.com › the main thread › stop letting ai guess in your java repository
Stop Letting AI Guess in Your Java Repository
April 22, 2026 - Expected result: java -version reports Java 21 or later, and Maven completes without BUILD FAILURE.
🌐
SDKMAN!
sdkman.io
Home | SDKMAN! the Software Development Kit Manager
Install Software Development Kits for the JVM such as Java, Scala, Kotlin and Groovy.
🌐
PTC
support.ptc.com › help › servicemaxcore › en › articles › SMAX_China › installing-openjdk-21.html
Installing OpenJDK 21
brew install openjdk@21 · 3. After installation, run the following commands as listed under Caveats: sudo ln -sfn /opt/homebrew/opt/openjdk@21/libexec/openjdk.jdk \ /Library/Java/JavaVirtualMachines/openjdk-21.jdk echo 'export PATH="/opt/homebrew/opt/openjdk@21/bin:$PATH"' >> ~/.bashrc ·
🌐
Homebrew
formulae.brew.sh › cask › semeru-jdk-open@21
Homebrew Formulae: semeru-jdk-open@21
brew install --cask semeru-jdk-open@21 · Name: IBM Semeru Runtime (JDK 21) Open Edition · Production-ready JDK with the OpenJDK class libraries and the Eclipse OpenJ9 JVM · https://developer.ibm.com/languages/semeru-runtimes/ Development: ...
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-on-mac
How to Install Java on Mac in 2026
February 20, 2026 - If you see zsh: command not found: brew you need to install Homebrew first. Follow the instructions at Install Homebrew. Run this command to check for an existing Java installation: ... You'll see one of two results. If Java is installed, you'll see output like this: openjdk version "25.0.1" 2025-10-21 ...
🌐
Oracle
jdk.java.net › 26
OpenJDK JDK 26.0.1 GA Release
Java SE 21 · Java SE 20 · Java SE 19 · Java SE 18 · Java SE 17 · Java SE 16 · Java SE 15 · Java SE 14 · Java SE 13 · Java SE 12 · Java SE 11 · Java SE 10 · Java SE 9 · Java SE 8 · Java SE 7 · Feedback · Report a bug · Archive · © 2026 Oracle Corporation and/or its affiliates ·