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

brew install openjdk@17 

Java will be installed here:

/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:

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

resp. for Intel

sudo 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:

17.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:

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

...give a try to sdkman, it's far 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.4.1-tem

Java will be installed here:

/Users/YOUR_USERNAME_HERE/.sdkman/candidates/java/17.0.4.1-tem
Answer from freedev on Stack Overflow
🌐
Oracle
docs.oracle.com › en › java › javase › 15 › install › installation-jdk-macos.html
Installation of the JDK on macOS
Any Intel-based computer running macOS. Administrator privileges. You cannot install Java for a single user. Installing the JDK on macOS is performed on a systemwide basis for all users.
🌐
Treehouse
treehouse.github.io › installation-guides › mac › jdk-mac.html
Installing Java SE Development Kit on Mac
Choose the JDK Download: Agree to terms and download the Mac OS X version · Open the dmg file and run the installation accepting all defaults · There are currently no reported issues.
Discussions

Which Java JDK do I download for Mac?
It seems you may have included a screenshot of code in your post " Which Java JDK do I download for Mac? ". If so, note that posting screenshots of code is against r/learnprogramming 's Posting Guidelines (section Formatting Code): please edit your post to use one of the approved ways of formatting code . (Do NOT repost your question! Just edit it.) If your image is not actually a screenshot of code, feel free to ignore this message. Automoderator cannot distinguish between code screenshots and other images. Please, do not contact the moderators about this message. Your post is still visible to everyone. 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/learnprogramming
3
0
September 14, 2021
macOS - How to install Java 17 - Stack Overflow
Then, open a Terminal, and extract the downloaded archive to the system path for Java virtual machines: cd Downloads tar xzf OpenJDK17U-jdk_aarch64_mac_hotspot_17.0.5_8.tar.gz -C /Library/Java/JavaVirtualMachines More on stackoverflow.com
🌐 stackoverflow.com
Installing JDK on a new mac

I'd recommend homebrew for package management in general and sdkman for java (and related ecosystem) development tools.

More on reddit.com
🌐 r/java
17
21
February 17, 2017
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
🌐
Apple Support
support.apple.com › en-us › 106384
Download Java for OS X 2017-001 - Apple Support
Keep your software up to date. If you need Java, download the latest version of Java for OS X directly from Oracle https://www.java.com
🌐
YouTube
youtube.com › programmingknowledge
How to Install Java on Mac | Install Java JDK on macOS (2024) - YouTube
🖥️ **Mastering Java on Mac: A Comprehensive Guide to Installing Java JDK on macOS! (M1, M2, M3, MacBook Pro, MacBook Air)☕🍏**export JAVA_HOME=$(/usr/libex...
Published   January 1, 2024
Views   126K
Find elsewhere
🌐
Compuscholar
compuscholar.com › docs › textbooks › instructions › Java_JDK_Install_Instructions_Mac.pdf pdf
Download and Installation Instructions Java JDK Software ...
Now your JDK is installed and ready to use. Upgrading Your Mac OS Java Version (from 10.6 or 10.7) If you have an older version of Java, you may want to upgrade your Java version to the most recent · version (currently version 1.8 or 8). This process is fairly simple on the Mac OS. The first step is to find the appropriate Java download for your Mac.
🌐
GeeksforGeeks
geeksforgeeks.org › java › download-and-install-jdk-on-windows-mac-and-linux
Download and Instal JDK on Windows, Mac and Linux
July 11, 2022 - This article describes the step-by-step process for installing and configuring the JDK on Windows, Mac and Linux. The JDK can be installed on the following Platforms: ... Go to the Official JDK website to download the file.
Top answer
1 of 13
400

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

brew install openjdk@17 

Java will be installed here:

/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:

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

resp. for Intel

sudo 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:

17.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:

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

...give a try to sdkman, it's far 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.4.1-tem

Java will be installed here:

/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:

/usr/libexec/java_home -V

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

export 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.

🌐
Oracle
oracle.com › java › technologies › downloads
Download the Latest Java LTS Free
JDK 25 will receive updates under the NFTC, until September 2028, a year after the release of the next LTS. 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. Linux · macOS · Windows · Documentation Download ·
🌐
OpenLogic
openlogic.com › openjdk-downloads
OpenJDK Downloads | OpenLogic
Free, quarterly builds of OpenJDK for Linux, Windows, and MacOS.
🌐
Oracle
java.com › zh-CN
Java | Oracle
来自 Java 管理者 Oracle 的免费 Java 开发工具包 (JDK) 下载和资源 · 开发人员下载 · 开发人员资源 · 企业资源 ·
🌐
Oracle
java.com › en › download › manual.jsp
Download Java
» What is Java » Remove older versions » Security » Support » Other help · This download is for end users who need Java for running applications on desktops or laptops. Java 8 integrates with your operating system to run separately installed Java applications.
🌐
Azul Systems
azul.com › home › azul downloads
Java 8, 11, 17, 21, 25 Download for Linux, Windows and macOS
September 23, 2025 - Click here to download the Azul Zulu Builds of OpenJDK for Java 8, 11, 17, 21, 25 for Linux, Windows and macOS. Also download Azul Platform Prime.
🌐
OpenJDK
openjdk.org
OpenJDK
JDK Updates · JMC · Jigsaw · Kona · Lanai · Leyden · Lilliput · Locale Enhancement · Loom · Memory Model Update · Metropolis · Multi-Language VM · Nashorn · New I/O · OpenJFX · Panama · Penrose · Port: AArch32 · Port: AArch64 · Port: BSD · Port: Haiku · Port: Mac OS X ·
🌐
Microsoft Learn
learn.microsoft.com › en-us › java › openjdk › download
Download the Microsoft Build of OpenJDK | Microsoft Learn
October 27, 2025 - curl -OL https://aka.ms/download-jdk/microsoft-jdk-25-linux-x64.tar.gz · macOS · curl -OL https://aka.ms/download-jdk/microsoft-jdk-25-macOS-x64.tar.gz · Windows · Invoke-WebRequest -Uri https://aka.ms/download-jdk/microsoft-jdk-25-wind...
🌐
OpenJDK
openjdk.org › install
OpenJDK: Download and install
Oracle's OpenJDK JDK binaries for Windows, macOS, and Linux are available on release-specific pages of jdk.java.net as .tar.gz or .zip archives.
🌐
Oracle
jdk.java.net › 25
OpenJDK JDK 25.0.1 GA Release
September 17, 2025 - Commercial builds of JDK 25.0.1 from Oracle, under a non-open-source license, can be found here. ... If you have difficulty downloading any of these files please contact [email protected].
🌐
GeeksforGeeks
geeksforgeeks.org › java › download-and-install-jdk-on-windows-mac-and-linux
Download and Install JDK on Windows, Mac and Linux - GeeksforGeeks
1 month ago - This article describes the step-by-step process for installing and configuring the JDK on Windows, Mac and Linux. The JDK can be installed on the following Platforms: ... Go to the Official JDK website to download the file.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › technotes › guides › install › mac_jdk.html
JDK 8 Installation for macOS
October 20, 2025 - This page describes how to install and uninstall JDK 8 for macOS computers.