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
🌐
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.
🌐
Oracle
java.com › en › download › help › mac_install.html
How do I install Java for my Mac?
5. The Install Wizard displays the Welcome to Java installation screen. Click Install · 6. The MacJRE Installer dialog appears, prompting the user to enter a password to continue.
🌐
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.
🌐
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
🌐
Medium
medium.com › @dimitrios_ › brew-your-java-on-a-m1-a-quick-guide-c28d17f2d256
Brew your java on a M1: A Quick Guide | by Jim Kapsalis | Medium
September 30, 2024 - Check out brew search cask-versions/java for options. ... Run sudo ln -sfn /usr/local/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk to make the system recognize your new JDK. ... This brief post provides a concise and informative guide to installing Java on a Mac M1 using Brew.
🌐
Medium
medium.com › @kirebyte › using-homebrew-to-install-java-jdk11-on-macos-2021-4a90aa276f1c
Using HomeBrew to Install Java JDK11 on MacOS (2021) | by Erick Gustavo López Siordia | Medium
August 5, 2021 - $ brew install java11 · If you skip this step the system won’t be able to find a java runtime for you to use. sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk · If you see something ...
🌐
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 - If you want to install an older ... this: $ brew install java11 · If you’ve done this a few times, you may have a few different version of Java installed liked me, and if you enter the following command it may look something like this: % ...
Find elsewhere
🌐
MacPaw
macpaw.com › how to › optimization › apps
How to install Java on your Mac
August 19, 2025 - For example, for version 21, it would be brew install openjdk@21 · Press Return and wait for the install to complete. If you don’t want to develop Java apps, but do want to be able to run them, you don’t need to install a Java SDK. You do, though, need to install a Java runtime environment because it is no longer installed as part of macOS...
🌐
Adam the Automator
adamtheautomator.com › install-java-on-mac
How to Install Java on Mac
November 30, 2022 - 4. Now, run the following brew install command to install java on your Mac.
🌐
Snyk
snyk.io › blog › install-java-on-macos
How to install Java on macOS | Snyk
April 17, 2024 - java -version openjdk version "17.0.9" 2023-10-17 OpenJDK Runtime Environment Homebrew (build 17.0.9+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.9+0, mixed mode, sharing) Finally, verify that OpenJDK is installed correctly by checking the Java version again: ... If OpenJDK is installed correctly, this command should display the version of OpenJDK you installed. And there you have it! You've successfully installed OpenJDK on macOS.
🌐
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: ...
🌐
Mac Install Guide
mac.install.guide › java › brew-cask
Brew Install Java - Easy Cask Method · 2026
Brew install Java on Mac. One command to install the recommended Temurin JDK. The cask method without PATH or symlink configuration. How to fix common Homebrew Java issues.
🌐
mixable Blog
mixable.blog › home › brew: install java on macos
brew: install Java on macOS | mixable Blog
May 23, 2024 - The following steps will guide you through the installation. ... % brew search java ==> Formulae app-engine-java java javacc jslint4java pdftk-java google-java-format java11 javarepl libreadline-java · Currently, there are two different version of Java: java and java11. To check the version of both, you can use the following commands: % brew info java openjdk: stable 16.0.1 (bottled) [keg-only] Development kit for the Java programming language https://openjdk.java.net/ Not installed From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/o/openjdk.rb License: GPL-2.0-only with Classpath-exception-2.0
🌐
DEV Community
dev.to › khairunnaharnowrin › install-java-in-macbook-m1m2m3-58fd
Install Java in macbook M1/M2/M3 - DEV Community
July 8, 2024 - (echo; echo 'eval "$(/opt/homebrew/bin/brew shellenv)"') >> /Users/user_name/.zprofile eval "$(/opt/homebrew/bin/brew shellenv)" ... Install JDK using Homebrew: Once Homebrew is installed, you can install the JDK for ARM-based Macs by running the following command: bash ... This will install the Temurin JDK, which is compatible with ARM-based Macs. Verify Installation: After installation, you can verify that Java is installed by running: bash
🌐
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.
🌐
Sourabh Bajaj
sourabhbajaj.com › java
Java | macOS Setup Guide - Sourabh Bajaj
If you see a non-empty output like ... you don't see the output like above then you need to install Java on your system · brew install openjdk ·...
🌐
TecAdmin
tecadmin.net › install-java-macos
How to Install JAVA on macOS – TecAdmin
April 26, 2025 - If anyone else is having problems with brew tap caskroom/cask, don’t brew tap just use brew cask and install java with `brew cask install java`. ... Thanks, Ruth, The article has been updated with latest versions. ... Just go to https://www.oracle.com/technetwork/java/javase/downloads/jdk12-downloads-5295953.html with an Oracle account…. ... Worked perfectly on my MAC.