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
🌐
GitHub
github.com › jbranchaud › til › blob › master › java › install-java-on-mac-with-brew.md
til/java/install-java-on-mac-with-brew.md at master · jbranchaud/til
$ brew info openjdk ... For the system Java wrappers to find this JDK, symlink it with sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk ...
Author   jbranchaud
🌐
Mac Install Guide
mac.install.guide › java › brew-cask
Brew Install Java - Easy Cask Method · 2026
This single command downloads and ... application. The @25 specifies Java 25, the current LTS version. If you enter brew install --cask temurin (without a version number), Homebrew will install the latest version....
🌐
DevQA
devqa.io › brew-install-java
How to Use Brew to Install Java on Mac
If not, you can install it via: $ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" If you already have brew installed, make sure you have the latest version by running the following command in a terminal
🌐
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: ...
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk
Homebrew Formulae: oracle-jdk
brew install --cask oracle-jdk · 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.json · Cask code: ...
🌐
Smart People I Know
smartpeopleiknow.com › 2023 › 10 › 23 › how-to-work-with-java-on-your-mac-including-having-multiple-versions-of-java-on-your-mac
How to work with Java on your Mac, including having multiple versions of Java on your Mac – Smart People I Know
October 23, 2023 - All you need is to enter the following: $ /bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)” Now that you have homebrew installed, you can…
Find elsewhere
🌐
GitHub
gist.github.com › gwpantazes › 50810d5635fc2e053ad117b39b597a14
How to install different JDK versions on MacOS with Homebrew · GitHub
i use monterey 12.7 and do NOT have /usr/local/opt too i found my java in the following location: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/bin and this path was found in my PATH ... $ brew install openjdk@8 ==> Fetching downloads for: openjdk@8 ✔︎ API Source openjdk@8.rb [Verifying 9.9KB/ 9.9KB] openjdk@8: The x86_64 architecture is required for this software.
🌐
GitHub
github.com › AdoptOpenJDK › homebrew-openjdk
GitHub - AdoptOpenJDK/homebrew-openjdk: AdoptOpenJDK HomeBrew Tap · GitHub
June 17, 2024 - $ brew tap AdoptOpenJDK/openjdk $ brew install --cask <version>
Starred by 1.8K users
Forked by 97 users
Languages   Ruby 87.6% | Shell 12.4%
🌐
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 ...
🌐
Reddit
reddit.com › r/mac › unable to install java 8 on mbp m4
r/mac on Reddit: Unable to install Java 8 on MBP M4
January 13, 2025 -

Hello,

I need Java for some applications and I just downloaded the latest Java installer (jre-8u431-macosx-aarch64) from Oracle aaand … it's not installing. It tries to install and says something like java could not be installed and "OS error code 1".

I searched for hours on Google and couldn't find anything. Did anyone have a solution to this? I'm running Sequoia 15.2.

🌐
TecAdmin
tecadmin.net › install-java-macos
How to Install JAVA on macOS – TecAdmin
April 26, 2025 - If anyone else is having problems ... been updated with latest versions. ... Just go to https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html with an Oracle account…....
🌐
Andrew Hoog
andrewhoog.com › posts › 3-ways-to-install-java-on-macos-2023
3 ways to install Java on macOS [2023] - Don't Panic
January 12, 2023 - The blog post discusses various methods to install Java on macOS, including downloading from java.com and using alternative installation tools like Homebrew or SDKMAN!
🌐
Codemia
codemia.io › home › knowledge hub › how to brew install java?
How to brew install java? | Codemia
January 27, 2025 - Update Homebrew: It is a good practice to update Homebrew before installing any packages to ensure you’re installing the latest versions. ... Search for Java Versions: To see the versions of Java that are available for installation, use the command:
🌐
GitHub
gist.github.com › jonjack › 898efa5ccc79c140533ed53e0b1edbad
Install Java on Mac OSX via Home-brew · GitHub
brew tap caskroom/cask brew tap caskroom/versions // we will also install the handy cask completions. brew install brew-cask-completion · We can check the various releases of Java that are available.
🌐
freeCodeCamp
freecodecamp.org › news › how-to-install-java-on-mac
How to Install Java on Mac in 2026
February 20, 2026 - This is a good choice if you don't use Homebrew. See Install Java on Mac for detailed instructions. Homebrew formula. The command brew install openjdk@25 installs a Homebrew-managed build.
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › how-to-install-openjdk-in-macos
How to Install OpenJDK in macOS - GeeksforGeeks
May 6, 2026 - If not, you will see a message saying Java is not installed. ... Homebrew is a package manager for macOS that makes it easy to install software like OpenJDK. To check if Homebrew is installed, run: ... Follow the on-screen instructions to complete the installation. ... Homebrew will download and install the latest version of OpenJDK.
🌐
Groups.io
groups.io › g › jmriusers › topic › installing_java_via_homebrew › 99910198
jmriusers@groups.io | Installing Java via Homebrew
October 31, 2023 - You logged in using a passkey from another device. For faster access next time, add a passkey to this device · I am documenting how to install Java11 on macOS via homebrew, so that this topic will pop up via search if you run into problems (like I did)