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/
thank you very much . I could not install java correctly until I read your article .
Hi thanks for the useful info.
In case there are multiple Java versions the following command used to return in the previous macOS release the path of a specific version:
/usr/libexec/java_home -v “1.8*”
The above command in macOS 11.0.1 returns only the latest Java version.
Is this a bug or I need to modify the above command?
Thanks Achilleas
Thank you!
thank you for the article, but while setting the JAVA_HOME, I had to hardcode the actual path of the JDK /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home. The provided one did not work for me
Thank you. Worked fine 🙂
Wolf, please make a comment to this one:
Excellent tutorial, but as it seems there is a major error in ALL Java JDK and JRE versions around when it comes to Big Sur, as follows:
Any application now need permission to access system resources, but Java JDK/JRE does not pose such request, nor is this available as an API for a Java application (?).
In consequence, and as an example: If a java app requests DEFAULT audio input device (often the built in mic, but sometimes virtual sound cards like e.g. Blackhole), then everything is ok. But, if the app request an input device NOT currently set as default input, then this is rejected by Big Sur, and there is no audio stream sent to the java App.
Comparing Java behaviour to other non-java apps like e.g. Reaper DAW, one observes that Reaper community has grasped this rule so that Reaper is requesting permission everywhere. It means the Reaper user does not need to think about it after accepting these requests in Apple System Preferences security. Again, a typical example is permission to use the microphone.
Comparing Java and Reaper, Java does not ask any such permissions anywhere, which means all Java Apps are completely stuck until this is fixed. Well, not completely, since a mic can be used by any app also Java as long as it is system default.
I hope it is me that has not grasped how to instruct Java to pose such permission to Big Sur, but I fear not, and then how do we fix this?
my email: chj@hdsoundlab.com
Carl
10000 Dank, sogar eine “Normalnutzerin” wie ich konnte damit endlich das Installationsproblem des JKD lösen. Wunderbar 🙂
Heike (München)
[…] a Prebuilt OpenJDK Binary. Easy to follow details about how to install OpenJDK are available here. Anyway, after opening the Terminal […]