Installing Java on macOS 10.15 Catalina

Looking for how to install Java on Big Sur? Please take a look over here.

Since OS X 10.7 Java is not (pre-)installed anymore, let’s fix that. As I’m writing this, Java 11.0.4 is the latest version and AdoptOpenJDK is one of the best places to find Prebuilt OpenJDK Binaries. Easy to follow details about how to install OpenJDK are available here.

However, the easiest way is to select OpenJDK 11 (LTS), the HotSpot JVM, and macOS x64, which will expose two option like these:

Clicking on “Install JDK installer”, will download the OpenJDK installer package, e.g. OpenJDK11U-jdk_x64_mac_hotspot_11.0.4_11.pkg, which when executed, will install into this location: /Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk

Almost done. After opening a terminal, the successful installation of the JDK can be confirmed like so:

java -version

… hopefully showing something like this:

openjdk 11.0.4 2019-07-16
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.4+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.4+11, mixed mode)

JAVA_HOME is an important environment variable and it’s important to get it right. Here is a trick that allows me to keep the environment variable current, even after a Java Update was installed. In ~/.zshrc, I set the variable like so:

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

In previous macOS versions, this was done in ~/.bash_profile. Now it’s done.

java --version
openjdk version "11.0.6" 2020-01-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.6+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.6+10, mixed mode)


Source Code

The source code of the Java Platform, Standard Edition 11 Reference Implementations binaries is available under the GPLv2 in a single zip file.

API Specification

The API Specification of the Java Platform, Standard Edition and Java Development Kit
can be found here:

11 Replies to “Installing Java on macOS 10.15 Catalina”

  1. Hi!!
    Any idea about how can I set the Classpath variable on Catalina?? I’m a newbie and I’m not sure how to do this…

    1. Try adding something like this to your ~/.zshrc file:
      export CLASSPATH=$CLASSPATH:/path/to/file/java-servlet-api.jar

  2. Any chance I can get a more detailed description on how to set JAVA_HOME on Catalina? The “For Dummies” version would be best for me.

    1. .. read above….
      Try adding something like this to your ~/.zshrc file:
      export JAVA_HOME=$(/usr/libexec/java_home)

      1. I followed all the instructions above and tried different methods, but still I have the issue when I issue a “sudo apt get update”
        Unable to locate an executable at “/Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home/bin/apt” (-1)
        I can see that the executable is in – /Library/Java/JavaVirtualMachines/jdk-16.jdk/Contents/Home/bin
        I don’t how to force the path stop at bin or is this something else?

  3. Hi!! I installed javaws from, but it does not work. Any idea? Thanks a lot

    % export JAVA_HOME=$(/usr/libexec/java_home)
    % java –version
    openjdk 11.0.5 2019-10-15
    OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.5+10)
    Eclipse OpenJ9 VM AdoptOpenJDK (build openj9-0.17.0, JRE 11 Mac OS X amd64-64-Bit Compressed References 20191031_374 (JIT enabled, AOT enabled)
    OpenJ9 – 77c1cf708
    OMR – 20db4fbc
    JCL – 775c5eb03a based on jdk-11.0.5+10)

    % echo $JAVA_HOME

    % javaws
    No Java runtime present, requesting install.
    Unable to locate a Java Runtime to invoke.

  4. Javier Mayorga says: Reply

    Thanks it works..

    If you are installing JAVA with CATALINA OS then make sure you are using the zsh terminal and that the .zshrc file is created in the ~/ directory.

    Then you need to edit the .zhrc using the command:
    VIM .zhrc.

    After executing the command make sure you set the JAVA_HOME environment variable, it would look something like this:

    export JAVA_HOME;

    Then after you have set your path exit using the ESCAPE key and save pressing :wq

    !Important: The path shown above is where my Java file is located.

    If you followed the instructions correctly you can now type on your terminal

    $JAVA_HOME/java -version

    java version “1.8.0_241”
    Java(TM) SE Runtime Environment (build 1.8.0_241-b07)

    Hope it works for you.

  5. Hi Wolf,

    This saved me a lot of time trying to get Apache Beam up and running with the JDK for Java 8. Thanks!

  6. Hi,
    I have installed OpendJDK 11. Please help for the below statement.
    Set JAVA_HOME and update PATH variable with $JAVA_HOME/bin extension.

  7. JAVA_HOME/bin extension

  8. I installed, as above, in Catalina …
    metheuser@AlsMini4 ~ % java –version
    openjdk 2022-08-12
    OpenJDK Runtime Environment Temurin- (build
    OpenJDK 64-Bit Server VM Temurin- (build, mixed mode)
    acellier@AlsMini4 ~ % echo $JAVA_HOME

    I am having an issue trying to run a java script named PVPower …
    “java.lang.UnsupportedClassVersionError: PVPower has been compiled by a more recent version of the Java Runtime (class file version 59.0), this version of the Java Runtime only recognizes class file versions up to 55.0”

    Any advice?

Leave a Reply