Installing Java on macOS 11 Big Sur

Since OS X 10.7 Java is not (pre-)installed anymore, let’s fix that. As I’m writing this, Java 11.0.9 is the latest LTS (Long Term Support) 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 is to get the latest release here:

https://adoptopenjdk.net/archive.html?variant=openjdk11&jvmVariant=hotspot

Select macOS and x64 and download the JDK (about 190 MB), which will put the OpenJDK11U-jdk_x64_mac_hotspot_11.0.9_11.pkg file into your ~/Downloads folder

Clicking on pkg file, 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.9 2020-10-20
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+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. Anyway, open a new terminal and verify:

echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jdk/Contents/Home

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: https://docs.oracle.com/en/java/javase/11/docs/api/


Share this post:

One Reply to “Installing Java on macOS 11 Big Sur”

  1. thank you very much . I could not install java correctly until I read your article .

Leave a Reply