Install OpenJDK on Mac aarch64

September 21, 2022
 
Finding the right JDK for your Apple M1 ARM CPU

If you have a newer mac with Apple hardware, then you'll want to install your JDK for the aarch64 (ARM architecture). I didn't easily find a compatible version so I'm posting here. You can always go to Oracle to get their version. In this article I will be installing the OpenJDK alternative.

First see if you have java installed on your Mac:
java -version
If it's found it will show you something like this:
openjdk version "11.0.16.1" 2022-08-12
OpenJDK Runtime Environment Temurin-11.0.16.1+1 (build 11.0.16.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.16.1+1 (build 11.0.16.1+1, mixed mode)
 
 

Adoptium is from Eclipse

Java 11 https://adoptium.net/temurin/releases/?version=11
 
I wanted to download all JDKs from the Eclipse Foundation, but I wasn't fortunate enough to find Java 8 available, so I grabbed from Azul.

Java 8 https://www.azul.com/downloads/?os=macos&architecture=arm-64-bit&package=jdk#download-openjdk  

After you have installed both versions, you can confirm using this command:
/usr/libexec/java_home -V

You should see something similiar to this:
Matching Java Virtual Machines (2):
11.0.16.1 (arm64) "Eclipse Adoptium" - "OpenJDK 11.0.16.1" /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home
1.8.0_345 (arm64) "Azul Systems, Inc." - "Zulu 8.64.0.19" /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home


To set Java 8 as your default JDK, you can edit your ~/.zshrc file to include the following:
export JAVA_HOME=`/usr/libexec/java_home -v 1.8`
export PATH=$JAVA_HOME/bin:$PATH

Linux Note: the quotes around the JAVA_HOME path are acute, which is different than a single quote. This is for command execution substitution. I always forget that. Use single quotes for literals

Close your terminal window, reopen it and check your java version now and you should see Java 8.


 
Return to articles