Installing OpenJDK on M1 Macbook Pro

Sudaraka Jayathilaka
2 min readDec 10, 2021

--

Image: https://www.macworld.com/article/346129/2021-macbook-pro-14-inch-16-inch-mini-led-m1x-touch-bar-price-release.html

I recently got hold of a M1 MacBook Pro and was faced with the challenge of setting up java developer env. I wanted to build and run a spring boot project. Naturally, I used the following commands to check and install the latest JDK using Homebrew

Checking available Java versions via Homebrew

$ brew search java

Output

==> Formulae
app-engine-java java javacc jslint4java pdftk-java
google-java-format java11 javarepl libreadline-java
==> Casks
homebrew/cask-versions/java-beta homebrew/cask/eclipse-java

Checking the details about the Formulae named java

$ brew info java

Output

openjdk: stable 16.0.1 (bottled) [keg-only]
Development kit for the Java programming language
https://openjdk.java.net/
Not installed
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/openjdk.rb
License: GPL-2.0-only with Classpath-exception-2.0
==> Dependencies
Build: autoconf ✘
==> Requirements
Build: Xcode ✘
==> Caveats
For the system Java wrappers to find this JDK, symlink it with
sudo ln -sfn /opt/homebrew/opt/openjdk/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk.jdk
This is a beta version of openjdk for Apple Silicon
(openjdk 17 preview).
openjdk is keg-only, which means it was not symlinked into /opt/homebrew,
because macOS provides similar software and installing this software in
parallel can cause all kinds of trouble.
==> Analytics
install: 152,874 (30 days), 463,335 (90 days), 1,705,669 (365 days)
install-on-request: 41,576 (30 days), 129,753 (90 days), 531,943 (365 days)
build-error: 0 (30 days)

So I saw details and went ahead with installation using,

brew install java

But then I faced this issue when compiling my spring boot project

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project reachup-api: Fatal error compiling: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x486dd616) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x486dd616 -> [Help 1]

So I realized, there is something wrong with the installation and went into reading some content on the web. Okay then I got to know Lombok is not supported in Java 17, and Brew installed java 17 on my machine.

So now I dug up a bit and found the solution. azul.com provides OpenJDK versions built for ARM 64-bit architecture. You can download the dmg from HERE 👋

Problem solved 😎

--

--