If you’re using command line tools on Mac, chances are you would benefit from using home brew. Installing home brew is pretty simple, just google it and it should give you a command to run in the terminal. After installing homebrew it’s easy enough to probably run a command like “brew install java11” or something like that. Google it and then you’ll prob find what you need Answer from MostWanted29 on reddit.com
🌐
Lehigh Computer Science
docs.cse.lehigh.edu › java › installing-java-11-mac
Installing Java JDK Version 11 on Mac OS - Lehigh Computer Science Docs
As mentioned above, the CSE and CSB-recommended version of Java is 11, the default download at Adoptium.net is version 17. Click on Other platforms and versions to find version 11: ... Before we can configure the filters to find the appropriate download, it is important to identify the architecture of the Mac where this Java software will be installed.
Discussions

macos - How do I install Java on Mac OSX allowing version switching? - Stack Overflow
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. More on stackoverflow.com
🌐 stackoverflow.com
Obtain Java 11 for macOS? - Ask Different
I know in recent years the Java development cadence has changed, becoming much more rapid and more predictably scheduled. New plans were announced for regular Long-Term Support (LTS) releases. And ... More on apple.stackexchange.com
🌐 apple.stackexchange.com
December 20, 2018
How to install Java 11 on macOS 10.14 Moj… - Apple Community
So my question is: How to install Java 11 on macOS Mojave? Java 10.0.2 is installed. More on discussions.apple.com
🌐 discussions.apple.com
November 7, 2018
What is the easiest way to install Java 11 on Macos?
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://imgur.com/a/fgoFFis ) 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
9
3
June 15, 2022
🌐
Oracle
docs.oracle.com › en › java › javase › 11 › install › installation-jdk-macos.html
5 Installation of the JDK on macOS - Java
July 15, 2025 - There can be multiple JDKs installed on the macOS system. You can determine which version of the JDK is the default by entering java -version in a Terminal window. If the installed version is 11 Interim 0, Update 0, and Patch 0, then you see a string that includes the text 11.
🌐
GitHub
gist.github.com › douglarek › bbda8cc23a562cb5d5798717d57bc9e9
How to install openJDK 11 on macOS - Gist - GitHub
Using mac os Big sur, I had to add the environment variable export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk-11.jdk/Contents/Home" in my ~/.zshrc file for it to work
🌐
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 - 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
Top answer
1 of 11
1214

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.

Copy/usr/libexec/java_home -V

Step 3: Edit .bash_profile

Copysudo nano ~/.bash_profile

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

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

to switch to any version

Copyexport 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

Copysource ~/.bash_profile

Step 6: Confirm current version of Java

Copyjava -version
🌐
GitHub
gist.github.com › drm317 › 3e2a9ce4ba1288c4fbaab1e534d71133
OpenJDK 11+ on MacOS X · GitHub
The installation directory is /Library/Java/JavaVirtualMachines/ which is the traditional location on MacOSX
Find elsewhere
🌐
Tutorials24x7
java.tutorials24x7.com › blog › how-to-install-java-11-on-mac
How To Install Java 11 On Mac | Tutorials24x7
April 22, 2020 - In this tutorial, we will discuss how to install Oracle Java 11 on Mac systems. This tutorial provides all the steps required to install the LTS version of Java i.e. Oracle Java 11 officially distributed by Oracle for Mac. It provides the steps required to install Java 11 on macOS Catalina.
🌐
Medium
medium.com › @rajkanchole1 › how-to-install-java-11-on-macos-a-step-by-step-guide-02ab0969ff78
How to Install Java 11 on macOS: A Step-by-Step Guide | by Rajj Kannchole | Medium
October 21, 2024 - How to Install Java 11 on macOS: A Step-by-Step Guide The below steps will help you in install Java 11 on your Mac machine. Step 1: Install Homebrew Homebrew is a package manager that makes …
Top answer
1 of 2
10

tl;dr

If you are an end-user needing a free-of-cost JVM to run a Java app on your Mac (rather than a developer), my personal recommendation is to download an .pkg file from AdoptOpenJDK.

Open that file to run a macOS installer.

You will then find a JVM installed in /Library/Java/JavaVirtualMachines. Later, you can upgrade in the same manner, deleting the old JVM from that folder.

Details

Yes, there have been several major changes to the evolution of Java in recent years, and they can be a bit confusing.

Multiple vendors, both free and paid

First, know that there are new options available for those wishing to pay for commercially supported implementations of Java. And know that Java is still available freely without cost. For both a summary as well as the gory details, read this white paper published by major figures in the Java community: Java Is Still Free

OpenJDK

Secondly, know that all releases for Java 11 and later for macOS are based on the same codebase, the open-source project known as OpenJDK.

Apple contributes Mac-specific code to this project, and has staff working on this to make sure that Java continues to work well on macOS.

IBM, Oracle, and many other companies have contributed code and testing as well. Oracle has recently announced their intention to reach feature-parity between their own Oracle-branded Java releases and the OpenJDK product; this even included the donation of some of their previously-commercial tools such as Flight Recorder to OpenJDK.

The upshot is that you should see very similar behavior and features across the various sources of Java for macOS.

JVM bundled within desktop apps

If you make desktop apps to run locally on a Mac or other computer, you may continue to do so, and keep on using Swing and/or JavaFX as always. But the delivery of your app will change.

Java Applet and Java Web Start technologies are being phased out. Oracle will no longer encourage end-users to have a JVM by itself installed. Instead, Oracle advises building your app as a standalone executable with a JVM bundled inside. This has already been commonly done on Macs, especially so if delivering an app through the Apple App Store. That approach is the new normal, to be done across all platforms including macOS, Windows, Linux, etc. The new Java Modularization technology that began with Java 9, including the jlink and jpackage tools, make it easier than ever to bundle a down-sized JVM with your app.

For more info, see the white paper Java Client Roadmap Update of 2018-03.

So, for the purpose of bundling with your app, you will need to consider redistribution/deployment rights when choosing a JVM vendor and product.

Choosing a vendor

Some major vendors of Java to consider for Java 11 and later:

  • Azul Systems
    Offering two product lines, Zulu based directly on OpenJDK with possibly a few tweaks, and Zing a specially-enhanced version of the Java platform.
  • Oracle
    Offering their own commercial product Oracle JDK and the quite-similar free-of-cost and GPL-licensed jdk.java.net.
  • AdoptOpenJDK.net
    Offering free-of-cost builds of Java based on OpenJDK. Choose between with the usual HotSpot engine (just-in-time compiler & optimizer) or the OpenJ9 engine from Eclipse (previously from IBM).

Here is a diagram chart that may help guide your decision-making. This chart is not necessarily complete or accurate. It is simply meant to help get you oriented. You should research further your options.


SDKMAN!

A subset of the vendors listed above choose to send their release information to the SDKMAN! project for your convenience.

SDKMAN! is an amazingly simple utility to locate, download, install, and uninstall JDKs, JREs, and other software kits such as Apache Maven, Gradle, etc.

If your JDK/JRE of choice is available via SDKMAN!, then I highly recommend that route.

2 of 2
6

If you want to have the simplest life possible, install homebrew and then install java with brew cask install java.

🌐
DZone
dzone.com › coding › java › installing openjdk 11 on macos
Installing OpenJDK 11 on MacOS
October 26, 2018 - This tutorial demonstrates how to download and install the OpenJDK 11 onto your MacOS devices, providing useful instructions and sample code to get you started.
🌐
Oracle
java.com › en › download › help › mac_install.html
How do I install Java for my Mac?
6. The MacJRE Installer dialog appears, prompting the user to enter a password to continue.
🌐
MacPorts
ports.macports.org › port › openjdk11
Install openjdk11 on macOS with MacPorts
OpenJDK 11 (Long Term Support) JDK 11 builds of OpenJDK, the Open-Source implementation of the Java Platform, Standard Edition, and related projects. ... If not done already, install MacPorts.
🌐
Medium
medium.com › w-logs › installing-java-11-on-macos-with-homebrew-7f73c1e9fadf
Installing Java 11 on MacOS with HomeBrew | by Wai Loon | w:Logs | Medium
January 27, 2019 - Installing Java 11 on MacOS with HomeBrew Prerequisite: HomeBrew Before we start Find locations of previously installed Java JDK: $ /usr/libexec/java_home -V Matching Java Virtual Machines (1): …
🌐
Medium
medium.com › java-mvp › 3-steps-to-install-openjdk-11-on-macos-3ae0e10dfa1a
3 Steps to Install OpenJDK 11 on macOS | by datatec.studio | Java MVP | Medium
October 13, 2023 - I used macOS Big Sur (11.7.2) as example. ... sudo rm -fr /Users/yourUserName/Library/Java/JavaVirtualMachines/* sudo rm -fr /Library/Java/JavaVirtualMachines/* /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" brew install openjdk@11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk java -version
🌐
Kontext
kontext.tech › home › blogs › java programming › install jdk 11 on macos
Install JDK 11 on macOS - Kontext Labs
September 6, 2022 - Go to JDK 11 download page: Java SE Development Kit 11- - Downloads (oracle.com). Download macOS Installer: jdk-11.0.9_osx-x64_bin.dmg
🌐
Snyk
snyk.io › blog › install-java-on-macos
How to install Java on macOS | Snyk
April 17, 2024 - For this tutorial, select the OpenJDK ... OpenJDK 11) and choose macOS as your operating system. After selection, click on the `Latest release` button to download the JDK. Once the download is complete, the installer file (.pkg) will be in your ...
🌐
javaspring
javaspring.net › blog › install-java-11-mac
Install Java 11 on Mac: A Comprehensive Guide — javaspring.net
... Open the.pkg file inside the mounted volume and follow the installation wizard's instructions. ... Visit the Adoptium website. Select the Java 11 version, your Mac's operating system, and architecture.
🌐
Apple Community
discussions.apple.com › thread › 8604278
How to install Java 11 on macOS 10.14 Moj… - Apple Community
November 7, 2018 - Uninstalled Java but it still shows up in Terminal I had downloaded both the JDK 20.0.2 and the Java 8 Update 381 on my MacBook Pro M1 2020 version macOS Monterey 12.2.1 to run a program that required Java. However, I couldn't run it no matter what I tried as it kept saying "Unable to load Java Runtime Environment" - I even asked a question about it on the Community just a few hours ago.