Install OpenJDK 17 on MacOS

datatec.studio
Java MVP
Published in
2 min readJan 17, 2023

--

17

Oracle JDK 17 ist currently the latest Long-Term Release of Java SE.

The Oracle JDK and OpenJDK builds are essentially identical from Java 11 onward. If you would like to know the different between them, there are lot of summary on the internet. e.g., the one from baeldung: Differences Between Oracle JDK and OpenJDK.

In this article, we will learn how to install OpenJDK on macOS.

In my previous blog, i have introduce you about 3 Steps to install OpenJDK 11 on macOS.

Actually, to install OpenJDK 17 is more or less the same.

Long story short, assume you don’t know which java you already have on your laptop, following steps might be help you to install OpenJDK 17 on your macOS.


java -version

# Ignore the output if it said "no matches found:"
sudo rm -fr /Users/$(whoami)/Library/Java/JavaVirtualMachines/*

# Ignore the output if it said "no matches found:"
sudo rm -fr /Library/Java/JavaVirtualMachines/*

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

brew uninstall openjdk@11

brew install openjdk@17

sudo ln -sfn /usr/local/opt/openjdk@17/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk

java -version

That’s all for today, if you find this post is helpful, please give a like or click on the “Follow” button on my medium blog, this will probably get the article suggested more and get more readers.

--

--