In 2024, even if you can use just brew..

Copybrew install openjdk@17 

Java will be installed here:

Copy/opt/homebrew/opt/openjdk@17/bin/java

for Apple Intel path is /usr/local/... rather than /opt/homebrew/...

For the system Java wrappers to find this JDK, symlink it with:

Copysudo ln -sfn /opt/homebrew/opt/openjdk\@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

resp. for Intel

Copysudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Now, running /usr/libexec/java_home -V should show the path to JAVA 17, something like:

Copy17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home

(This is what you are missing btw, if javac or javac --version does not give you a command-not-found but an The operation couldn’t be completed. Unable to locate a Java Runtime.)

In case you see the wrong version, check if the path to JAVA_HOME is set correctly. If not, you could set it by:

Copyexport JAVA_HOME=\$(/usr/libexec/java_home)

...give a try to sdkman, it's far better than brew

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

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

Copysdk list java 

At time of writing you could use:

Copysdk install java 17.0.4.1-tem

Java will be installed here:

Copy/Users/YOUR_USERNAME_HERE/.sdkman/candidates/java/17.0.4.1-tem
Answer from freedev on Stack Overflow
Top answer
1 of 13
407

In 2024, even if you can use just brew..

Copybrew install openjdk@17 

Java will be installed here:

Copy/opt/homebrew/opt/openjdk@17/bin/java

for Apple Intel path is /usr/local/... rather than /opt/homebrew/...

For the system Java wrappers to find this JDK, symlink it with:

Copysudo ln -sfn /opt/homebrew/opt/openjdk\@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

resp. for Intel

Copysudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk

Now, running /usr/libexec/java_home -V should show the path to JAVA 17, something like:

Copy17.0.9 (x86_64) "Homebrew" - "OpenJDK 17.0.9" /opt/homebrew/Cellar/openjdk@17/17.0.9/libexec/openjdk.jdk/Contents/Home

(This is what you are missing btw, if javac or javac --version does not give you a command-not-found but an The operation couldn’t be completed. Unable to locate a Java Runtime.)

In case you see the wrong version, check if the path to JAVA_HOME is set correctly. If not, you could set it by:

Copyexport JAVA_HOME=\$(/usr/libexec/java_home)

...give a try to sdkman, it's far better than brew

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

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

Copysdk list java 

At time of writing you could use:

Copysdk install java 17.0.4.1-tem

Java will be installed here:

Copy/Users/YOUR_USERNAME_HERE/.sdkman/candidates/java/17.0.4.1-tem
2 of 13
56

Java doesn't mind if you install multiple versions. This is often required; java is not backwards compatible (it tries to change little, but e.g. the java8 to java9 transition broke a ton of stuff, much of it needless and much of it not reasonably expectable or fixable by libraries and apps, so a bunch of java apps and libraries only run on java8 - just an example).

So, yes, you have installed JDK17. Also, yes, if you just run java without specifying which one you want, you so happen to get java13 here.

To see all installed javas, you can run:

Copy/usr/libexec/java_home -V

to 'override', you can use something like (depends on which shell you're using on your mac):

Copyexport JAVA_HOME=`/usr/libexec/java_home -v 17`

(the backticks mean: Run this then take the output of it and treat that as the 'value' of the expression. here, assign it to the JAVA_HOME env var. -v 17 requests a path to java 17. The -V option lists all and is meant for your eyeballs, not for scripts. The -v option is mostly for scripting, and that's how we're using it here).

JAVA_HOME decides which java is used by some things, but the java you get when you just type java is /usr/bin/java, and that executable is actually just a wrapper that picks a java to run from amongst all installed versions. It uses JAVA_HOME to decide which java to actually run. There are wrappers for all the common commands (javac, too). You can always run e.g. which javac to see what that actually runs; you probably see /usr/bin/javac. Everything in /usr/bin is one of these wrapper thingies that looks at JAVA_HOME and then runs the binary it finds there.

🌐
Homebrew
formulae.brew.sh › formula › openjdk@17
Homebrew Formulae: openjdk@17
brew install openjdk@17 · 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@17.json · Formula ...
Discussions

How to install Java on Macbook
Hello guys i need to install java(not java script) i dont understand how,i installed in oracle " jdk23" i watched a youtube video where the youtuber writes something in terminal i dont get it : More on forum.freecodecamp.org
🌐 forum.freecodecamp.org
0
0
October 9, 2024
How to install Java on macOS Sonoma? - Apple Community
it’s been a while since I installed it (that was a link to Java 17 back then). More on discussions.apple.com
🌐 discussions.apple.com
Oracle released native Apple Silicon Java JDK 17

Not sure when Open JDK released it, but it's there too https://jdk.java.net/17/

[ edit ] It was released on August 7th this year.https://openjdk.java.net/jeps/391 [/ edit ]

More on reddit.com
🌐 r/MacOS
13
50
September 22, 2021
How do I install java for Mac
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
5
May 16, 2025
🌐
Medium
medium.com › @haroldfinch01 › step-by-step-guide-installing-and-switching-java-versions-on-mac-osx-f3896b9872f4
Step-by-Step Guide: Installing and Switching Java Versions on Mac OSX | by Harold Finch | Medium
May 21, 2024 - brew install openjdk@11 · Install Java 17 · brew install openjdk@17 · After installing each version, follow the instructions provided by Homebrew to add the Java versions to your PATH. jenv is a Java environment manager that makes it easy ...
🌐
Oracle
docs.oracle.com › en › java › javase › 17 › install › installation-jdk-macos.html
5 Installation of the JDK on macOS - Java
April 21, 2026 - For example, JDK 17.0.1 is installed in /Library/Java/JavaVirtualMachines/jdk-17.jdk.
🌐
Homebrew
formulae.brew.sh › cask › oracle-jdk@17
Homebrew Formulae: oracle-jdk@17
brew install --cask oracle-jdk@17 · 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@17.json · Cask ...
🌐
Snyk
snyk.io › blog › install-java-on-macos
How to install Java on macOS | Snyk
April 17, 2024 - brew install openjdk@11 · You can replace '11' with the version number of OpenJDK you want to install. At the time of writing this article, the following OpenJDK Java releases are available on Homebrew: openjdk@8 · openjdk@9 · openjdk@11 · openjdk@17 · You should see a message displaying the version of the installed Java, which should match the version you installed.
Find elsewhere
🌐
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.
🌐
GitHub
github.com › orgs › Homebrew › discussions › 1594
'brew install openjdk' install jdk 17 but shows version as 16. How to install openjdk 16? · Homebrew · Discussion #1594
Wanted to install openjdk 16 on macOS (macOS Big Sur 11.0.1; Apple M1). brew info openjdk shows as 16.0.1 but on install actual install version 17. How can I install openjdk 16 ? ... $ java -version openjdk version "17" 2021-09-14 OpenJDK Runtime Environment Homebrew (build 17+0) OpenJDK 64-Bit Server VM Homebrew (build 17+0, mixed mode) OR $ /usr/libexec/java_home -V Matching Java Virtual Machines (1): 17 (arm64) "Homebrew" - "OpenJDK 17" /opt/homebrew/Cellar/openjdk/16.0.1/libexec/openjdk.jdk/Contents/Home /opt/homebrew/Cellar/openjdk/16.0.1/libexec/openjdk.jdk/Contents/Home
🌐
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 ...
🌐
Medium
medium.com › java-mvp › guide-setting-up-and-switching-between-java-11-and-17-on-macos-9caff4c96e2d
Guide: Setting Up and Switching between Java 11 and 17 on macOS | by datatec.studio | Java MVP | Medium
November 25, 2023 - sudo rm -rf /Library/Developer...ercontent.com/Homebrew/install/HEAD/install.sh)" brew install openjdk@17 # The latest version openjdk 17.0.8.1 2023-08-24 should be outputed as version… ... Guide for build and deploy Java Applications....
🌐
Homebrew
formulae.brew.sh › cask › corretto@17
Homebrew Formulae: corretto@17
brew install --cask corretto@17 · Name: AWS Corretto JDK · OpenJDK distribution from Amazon · https://corretto.aws/ Development: Pull requests · Cask JSON API: /api/cask/corretto@17.json · Cask code: corretto@17.rb on GitHub · Current ...
🌐
Besu-eth
docs.besu-eth.org › how to › install and update java
Install and update Java | Besu documentation
1 month ago - ... To update the JDK version (for example, from 21 to 25), uninstall the old version and reinstall the target version: ... If you installed a version of Java not using Homebrew, it is located at /Library/Java/JavaVirtualMachines and can be safely deleted from that directory.
🌐
Oracle
oracle.com › java › technologies › javase › jdk17-archive-downloads.html
Java Archive Downloads - Java SE 17.0.12 and earlier
The archive downloads for JDK 17 updates 17.0.13 and greater are offered under different license terms, and can be found here. The JDK is a development environment for building applications using the Java programming language.
🌐
Oracle
oracle.com › java › technologies › downloads
Download the Latest Java LTS Free
Download the Java including the latest version 17 LTS on the Java SE Platform. These downloads can be used for any purpose, at no cost, under the Java SE binary code license.
🌐
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 ·
🌐
GitHub
github.com › orgs › Homebrew › discussions › 5173
Unable to install openjdk@17 latest version on M1 mac · Homebrew · Discussion #5173
Warning: openjdk@17 17.0.7 is already installed and up-to-date. To reinstall 17.0.7, run: brew reinstall openjdk@17
🌐
Se-education
se-education.org › guides › tutorials › javaInstallationMac.html
Java 17 Installation Guide for Mac Users
This guide explains how to install the (specifically, Java 17 JDK+FX Azul distribution) on macOS using SDKMAN.
🌐
freeCodeCamp
forum.freecodecamp.org › t › how-to-install-java-on-macbook › 715540
How to install Java on Macbook - The freeCodeCamp Forum
October 9, 2024 - Hello guys i need to install java(not java script) i dont understand how,i installed in oracle " jdk23" i watched a youtube video where the youtuber writes something in terminal i dont get it :
🌐
Bell Software
bell-sw.com › pages › downloads
Download JDK 8, 11, 17, 21, 25, 26 | Java Builds for Linux, Windows and macOS
Download Liberica JDK, supported OpenJDK builds. Open source Java 8, 11 and more for Linux, Windows, macOS.
🌐
Apple Community
discussions.apple.com › thread › 255283838
How to install Java on macOS Sonoma? - Apple Community
At Java.com there is a link "If you are running on an M series system (ARM64), download the ARM64 version of the JRE ." Today that downloads Java 8 update 391. When I first tried installing Java runtime on my new MacBook Pro M3 Pro shipped December, 2023, now running Sonoma 14.2.1, it failed.