A command line approach (thanks to the Homebrew team and the hard work of @vladimir-kempik and other openjdk contributors on the JEP-391 branch)

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install OpenJDK
brew install openjdk

Verify it's installed:

$(brew --prefix openjdk)/bin/java --version

Verify it's for the arm64 hardware:

file $(brew --prefix openjdk)/bin/java     
# /opt/homebrew/opt/openjdk/bin/java: Mach-O 64-bit executable arm64

Note: To install openjdk system-wide, follow the on-screen instructions provided by Homebrew.

Answer from tresf on Stack Overflow
🌐
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.
Discussions

macos - Java/JDK for the Apple Silicon chips - Stack Overflow
The Adoptium project recently published their first M1 release for Java 17. adoptium.net/…. 2021-12-17T03:05:44.51Z+00:00 ... Azul is offering macOS ARM builds of OpenJDK on their website in the Downloads section. I haven’t tried them out yet though, but Azul have been long-time JDK developers. More on stackoverflow.com
🌐 stackoverflow.com
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
How do I download Java on my MacBook Pro? - Apple Community
So I'm trying to download the latest version of Java (JDK 22) x64 DMG Installer from oracle and I get through and Download it and it says Download success but I then try to run it in terminal to make sure it's downloaded and it's not showing up. After the download is successful, it disappears, and Terminal can't find it, and it's like it didn't download in the first place. Both me and my more tech-savvy friend have tried, and it's just not showing up. I have a Macbook ... More on discussions.apple.com
🌐 discussions.apple.com
Installing Java on macOS - Zotero Forums
The install instructions for word processing plugins are scant, and should cover the JVM download and install because the web of instruction page on Oracle website are scant, incorrect and in my case not even remotely like what I'm seeing once I download the .tar.gz file from the Oracle server. These are my steps so far: 1. the Zotero installer (a typical macOS installer application) stops and says I need the Java Development Kit (JDK... More on forums.zotero.org
🌐 forums.zotero.org
December 8, 2023
🌐
Oracle
docs.oracle.com › en › java › javase › 15 › install › installation-jdk-macos.html
Installation of the JDK on macOS
To run a different version of Java, either specify the full path, or use the java_home tool. For example: $ /usr/libexec/java_home -v 15 --exec javac -version ... Download the JDK .dmg file, jdk-15.interim.update.patch_osx-x64_bin.dmg from Java SE Downloads page.
Top answer
1 of 16
210

A command line approach (thanks to the Homebrew team and the hard work of @vladimir-kempik and other openjdk contributors on the JEP-391 branch)

# Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install OpenJDK
brew install openjdk

Verify it's installed:

$(brew --prefix openjdk)/bin/java --version

Verify it's for the arm64 hardware:

file $(brew --prefix openjdk)/bin/java     
# /opt/homebrew/opt/openjdk/bin/java: Mach-O 64-bit executable arm64

Note: To install openjdk system-wide, follow the on-screen instructions provided by Homebrew.

2 of 16
127

Yes.

On this page: AdoptOpenJDK Latest Releases you can select 'macOS' from the 'Operating System' dropdown, and then from 'Architecture', it's currently only x64, but soonish there should be AArch64 or ARM64 (those are usually the shortcodes for 64-bit ARM). Possibly, as Apple no doubt has a bunch of extensions built into their M1 designs, and Apple gets its own.

If you instead leave Operation System on 'any', you'll note aarch64 is in there, and this gets you to a Linux release for ARM processors. That (probably) won't run on macOS on M1 hardware, but that's 95% of the work already done.

So: It's not there yet, but note that JDKs for ARM have been available for more than decade, and whilst JDK 15 has dropped support for a bunch of exotic OS/architecture combinations (such as Solaris), ARM development has always remained at least partially relevant (even if so far it's mostly an Oracle commercial license offering). That is to say: It should not be a herculean effort to create an adoptopenjdk release that runs on M1s natively, so presumably, it will happen. But, it's an open source effort, so if you're anxious, by all means, read up and contribute :)

Apple has not given any details on this architecture whatsoever until November 10th 2020, unless you bought a development kit box for it (a Mac Mini with an A14 chip, which isn't an M1 chip, but close enough I guess), and signed a big NDA.

As a rule, open source projects will run as fast as possible in the opposite direction if you wave an NDA around, so if you dislike this state of affairs, I don't think it's wise to complain to adoptopenjdk or other packagers and open source projects about it :)

Fortunately, now it's out, and an NDA is no longer required. My assumption is that the ARM branch of the OpenJDK source code + the macOS bits that already exist for the macOS x64 release can be combined rather easily once someone with some familiarity with the OpenJDK source code has an M1-based macOS system to test it on, which should mean an adoptopenjdk macos-aarch64 release should be here within the month.

But, open source. You didn't pay them, you have no contract, and they don't owe it to you. Donate to the effort or contribute a pull request if you want it to go faster.

UPDATE:

  • Azul's M1 OpenJDK builds
  • Microsoft's (yes, really) GitHub source repo for an early access OpenJDK16 build for macOS on AArch64. Note that Microsoft's been working on the OpenJDK branch of AArch64 (for ARM-based Windows 10) for a while, which goes back to: A lot of the hard work was already done.
🌐
Oracle
java.com › en › download › help › mac_install.html
How do I install Java for my Mac?
1. Download the jre-8u311-macosx-x64.dmg file. Review and agree to the terms of the license agreement before downloading the file. ... 4. Double-click on the .app icon to launch install Wizard. You might be prompted with message indicating app being downloaded from the Internet.
🌐
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 - These instructions are compatible with various versions of macOS, including Mojave, Catalina, Big Sur, Monterey, Ventura, Sonoma the latest macOS Sequoia. Proceed to Install the JDK kit by following the bootstrapped steps: ... Open the terminal and pass the following commands. To find the Location of the JAVA_HOME, run this command:
Find elsewhere
🌐
OpenLogic
openlogic.com › openjdk-downloads
OpenJDK Downloads | OpenLogic
Free, quarterly builds of OpenJDK for Linux, Windows, and MacOS.
🌐
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 - These instructions are compatible with various versions of macOS, including Mojave, Catalina, Big Sur, Monterey, Ventura, Sonoma the latest macOS Sequoia. Proceed to Install the JDK kit by following the bootstrapped steps: ... Open the terminal and pass the following commands. To find the Location of the JAVA_HOME, run this command:
🌐
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.
🌐
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 ·
🌐
Oracle
java.com › zh-CN
Java | Oracle
来自 Java 管理者 Oracle 的免费 Java 开发工具包 (JDK) 下载和资源 · 开发人员下载 · 开发人员资源 · 企业资源 ·
🌐
GeeksforGeeks
geeksforgeeks.org › installation guide › download-and-install-jdk-on-windows-mac-and-linux
Download and Install Java Development Kit (JDK) on ...
August 26, 2025 - These instructions are compatible with various versions of macOS, including Mojave, Catalina, Big Sur, Monterey, Ventura, Sonoma the latest macOS Sequoia. Proceed to Install the JDK kit by following the bootstrapped steps: ... Open the terminal and pass the following commands. To find the Location of the JAVA_HOME, run this command:
🌐
Apple Community
discussions.apple.com › thread › 255621210
How do I download Java on my MacBook Pro? - Apple Community
So I'm trying to download the latest version of Java (JDK 22) x64 DMG Installer from oracle and I get through and Download it and it says Download success but I then try to run it in terminal to make sure it's downloaded and it's not showing up. After the download is successful, it disappears, and Terminal can't find it, and it's like it didn't download in the first place. Both me and my more tech-savvy friend have tried, and it's just not showing up. I have a Macbook ...
🌐
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
🌐
Zotero Forums
forums.zotero.org › discussion › 110053 › installing-java-on-macos
Installing Java on macOS - Zotero Forums
December 8, 2023 - When I double click the DL file it doesn't produce a .dmg file or a macOS binary, it produces the application directory that presumably would want to get installed into /Library/Java/… 4. Been right through the Oracle documentation including this: (https://docs.oracle.com/en/java/javase/21/install/installation-jdk-macos.html#GUID-F575EB4A-70D3-4AB4-A20E-DBE95171AB5F) and it offers zero clues (or fucks obviously) that the download is decompressing into not what they claim it will, not a binary and not a macOS disk image. should I attempt to cp the whole directory into /Library/Java/JavaVirtualMachines (which already exists but is an empty directory far as I can tell with `ls -A` )? ... Please start new threads for new issues.
🌐
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
🌐
Treehouse
treehouse.github.io › installation-guides › mac › jdk-mac.html
Installing Java SE Development Kit on Mac
The installation process is very straight forward: Navigate to the Java SE Downloads page · 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.
Top answer
1 of 11
1209

Note: These solutions work for various versions of Java including Java 8 through Java 21 (the LTS version). This includes alternative JDK's from OpenJDK, Oracle, IBM, Azul, Amazon Correto, Graal and more.

You have a few options for how to do the installation as well as manage JDK switching. Installation can be done by Homebrew, SDKMAN, asdf, or a manual install. Switching can be done by SDKMAN, asdf, or manually by setting JAVA_HOME. All of these are described below.


TL;DR - Preferred Methods of Installation

You can install Java using whatever method you prefer including SDKMAN, asdf, Homebrew, or a manual install of the tar.gz file. The advantage of a manual install is that the location of the JDK can be placed in a standardized location for Mac OSX.

However, there are easier options such as SDKMAN and asdf that also will install other important and common tools for the JVM. These two primary options are described here.

Installing and Switching versions with SDKMAN

SDKMAN is a bit different and handles both the install and the switching. SDKMAN also places the installed JDK's into its own directory tree, which is typically ~/.sdkman/candidates/java. SDKMAN allows setting a global default version, and a version specific to the current shell.

  1. Install SDKMAN from https://sdkman.io/install

  2. List the Java versions available to make sure you know the version ID

    sdk list java
    
  3. Install one of those versions, for example, Java 21 LTS:

    sdk install java 21-open 
    

    Or java 19:

    sdk install java 19.0.2-open
    
  4. Make Java 17 the default version:

    sdk default java 17-open
    

    Or switch to 17 for the current terminal session:

    sdk use java 17-open
    

When you list available versions for installation using the list command, you will see a wide variety of distributions of Java:

sdk list java

And install additional versions, such as JDK 11 from Amazon:

sdk install java 11.0.14.10.1-amzn

SDKMAN can work with previously installed existing versions. Just do a local install giving your own version label and the location of the JDK:

sdk install java my-local-13 /Library/Java/JavaVirtualMachines/jdk-13.jdk/Contents/Home

And use it freely:

sdk use java my-local-13

SDKMAN will automatically manage your PATH and JAVA_HOME for you as you change versions. And as a note, it installs Java versions to ~/.sdkman/candidates/java/.

More information is available in the SDKMAN Usage Guide along with other SDK's it can install and manage such as Gradle, Maven, Kotlin, Quarkus, Spring Boot, and many others.


Installing and Switching versions with "asdf"

asdf is a version manager that supports installing and managing most languages, frameworks, and developer/devops tools. It has language specific plugins including one for Java.

  1. First, install asdf via https://asdf-vm.com/guide/getting-started.html (read there to setup your shell correctly), or more simply:

    brew reinstall asdf
    

    and read the doc for setting up your shell correctly, but if you are using asdf from Homebrew with ZSH you can execute this command to finish setup:

    echo -e "\n. $(brew --prefix asdf)/libexec/asdf.sh" >> ${ZDOTDIR:-~}/.zshrc
    
  2. Then install the Java plugin via https://github.com/halcyon/asdf-java

    asdf plugin add java
    

    and read the doc for setting up your shell correctly before continuing. Basically it says to add the following to your ~/.zshrc file (assuming you are not using another shell):

    . ~/.asdf/plugins/java/set-java-home.zsh
    
  3. Now list Java versions:

    asdf list-all java
    
  4. Install your favorite flavor and version:

    asdf install java openjdk-21
    

    or install the latest:

    asdf install java latest
    

Other important commands are...

  • List your installed versions:

    asdf list java
    
  • Set a global Java version:

    asdf global java openjdk-21
    
  • Set a local Java version for a directory:

    asdf local java openjdk-19
    

It's that easy! asdf will automatically manage your PATH and JAVA_HOME for you as you change versions. As a note, asdf installs Java versions to ~/.asdf/installs/java.

There are other languages and plugins for asdf here from the repository page: https://github.com/asdf-vm/asdf-plugins


Other Methods of Installation

Install with Homebrew

The version of Java available in Homebrew Cask previous to October 3, 2018 was indeed the Oracle JVM. Now, however, it has now been updated to OpenJDK. Be sure to update Homebrew and then you will see the lastest version available for install.

  1. install Homebrew if you haven't already. Make sure it is updated:

     brew update
    
  2. Add the casks tap:

     brew tap homebrew/cask-versions
    

    These casks change their Java versions often, and there might be other taps out there with additional Java versions.

  3. Look for installable versions:

     brew search java  
    

    or for Eclipse Temurin versions:

     brew search temurin     
    
  4. Check the details on the version that will be installed:

     brew info java
    

    or for the Temurin version:

     brew info temurin
    
  5. Install a specific version of the JDK such as java11, temurin8, temurin11, temurin17, or just java or temurin for the most current of that distribution. For example:

     brew install java
    
     brew install --cask temurin
    

And these will be installed into /Library/Java/JavaVirtualMachines/ which is the traditional location expected on Mac OSX. There might be additional steps to make the JDK active reported at the end of the install process.

Install manually from OpenJDK download page:

If you need any and every version of Java, this is a good place to look.

  1. Download OpenJDK for Mac OSX from http://jdk.java.net/ (for example Java 17 and Java 21)

  2. Unarchive the OpenJDK tar, and place the resulting folder (i.e. jdk-19.jdk) into your /Library/Java/JavaVirtualMachines/ folder since this is the standard and expected location of JDK installs. You can also install anywhere you want in reality.

  3. Set JAVA_HOME environment variable to point at direction where you unarchived the JDK.

For further information see the answer specific to manual installation. Also see the section below "Switching versions manually" for more information on how to manage multiple manual installations.

Other installation options:

Some other flavours of OpenJDK are:

Azul Systems Java Zulu certified builds of OpenJDK can be installed by following the instructions on their site.

Zulu is a certified build of OpenJDK that is fully compliant with the Java SE standard. Zulu is 100% open source and freely downloadable. Now Java developers, system administrators, and end-users can enjoy the full benefits of open source Java with deployment flexibility and control over upgrade timing.

Amazon Correto OpenJDK builds have an easy to use an installation package for Java 8, 11, 17, and Java 21. It installs to the standard /Library/Java/JavaVirtualMachines/ directory on Mac OSX.

Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK). Corretto comes with long-term support that will include performance enhancements and security fixes. Amazon runs Corretto internally on thousands of production services and Corretto is certified as compatible with the Java SE standard. With Corretto, you can develop and run Java applications on popular operating systems, including Linux, Windows, and macOS.

Microsoft Java JDK - certified builds of OpenJDK from Microsoft.


Where is my JDK?!?!

To find locations of previously installed Java JDK's installed at the default system locations, use:

/usr/libexec/java_home -V

Matching Java Virtual Machines (4):
19 (x86_64) "Homebrew" - "OpenJDK 19" /usr/local/Cellar/openjdk/19/libexec/openjdk.jdk/Contents/Home
18.0.1.1 (x86_64) "Homebrew" - "OpenJDK 18.0.1.1" /usr/local/Cellar/openjdk/18.0.1.1/libexec/openjdk.jdk/Contents/Home
17 (x86_64) "Homebrew" - "OpenJDK 17" /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home
11, x86_64: "Java SE 11" /Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home
1.8.301.09 (x86_64) "Oracle Corporation" - "Java" /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home /usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home

You can also report just the location of a specific Java version using -v. For example for Java 17:

/usr/libexec/java_home -v 17

/usr/local/Cellar/openjdk/17/libexec/openjdk.jdk/Contents/Home

Knowing the location of the installed JDK's is also useful when using tools like JEnv, or adding a local install manually to SDKMAN -- and you need to know where to find them.

If you need to find JDK's installed by other tools, check these locations:

  • SDKMAN installs to ~/.sdkman/candidates/java/
  • asdf install to ~/.asdf/installs/java

Version Switching

If you are using SDKMAN or asdf you are already covered and can stop reading! Otherwise, here are some options to switch existing VM installations.

Switching versions manually

The Java executable is a wrapper that will use whatever JDK is configured in JAVA_HOME, so you can change that to also change which JDK is in use.

For example, if you installed or untar'd JDK 16 to /Library/Java/JavaVirtualMachines/jdk-16.jdk if it is the highest version number it should already be the default, if not you could simply set:

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home

And now whatever Java executable is in the path will see this and use the correct JDK.

A simple way to change JDKs is to create a function in your ~/.bashrc or ~/.zshrc file:

jdk() {
    version=$1
    export JAVA_HOME=$(/usr/libexec/java_home -v"$version");
    java -version
}

And then change JDKs simply by:

jdk 1.8
jdk 9
jdk 11
jdk 13

Edits:

  • removed Jabba and JENV as both appear to have stagnated, issue count is climbing dramatically, and issues/PR's are not being addressed by the maintainers.
2 of 11
41

This is how I did it.

Step 1: Install Java 11

You can download Java 11 dmg for mac from here: https://www.oracle.com/technetwork/java/javase/downloads/jdk11-downloads-5066655.html

Step 2: After installation of Java 11. Confirm installation of all versions. Type the following command in your terminal.

/usr/libexec/java_home -V

Step 3: Edit .bash_profile

sudo nano ~/.bash_profile

Step 4: Add 11.0.1 as default. (Add below line to bash_profile file).

export JAVA_HOME=$(/usr/libexec/java_home -v 11.0.1)

to switch to any version

export JAVA_HOME=$(/usr/libexec/java_home -v X.X.X)

Now Press CTRL+X to exit the bash. Press 'Y' to save changes.

Step 5: Reload bash_profile

source ~/.bash_profile

Step 6: Confirm current version of Java

java -version