Navigate back to the homepage

Installing OpenJDK on M1 Mac

Sudaraka Jayathilaka
December 10th, 2021 · 2 min read

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

Checking available Java versions via Homebrew

1$ brew seach java
2

Output

1==> Formulae
2app-engine-java java javacc jslint4java pdftk-java
3google-java-format java11 javarepl libreadline-java
4==> Casks
5homebrew/cask-versions/java-beta homebrew/cask/eclipse-java
6

Checking the details about the Formulae named java

1$ brew info java
2

Output

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

So I saw details and went ahead with installation using,

1brew install java
2

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

1[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]
2

So I realised, 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 digged 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 🤓

More articles from Sudaraka Jayathilaka

Go Embed instead of Packr

Many of the microservices I am working right now, are written in Golang. Most of these microservices have internal dashboards and the UI…

December 6th, 2021 · 2 min read

Tackling High Cardinality Tags in Metrics

I wanted to share how I tackled the problem of high cardinality tags in a certain metric. But first, let me give some context around the…

December 22nd, 2024 · 4 min read
© 2021–2024 Sudaraka Jayathilaka
Link to $mailto:sudarakayasindu@gmail.comLink to $https://github.com/sudaraka94Link to $https://www.linkedin.com/in/sudarakajayathilaka/Link to $https://x.com/sudaraka94Link to $https://medium.com/@sudarakayasindu