3 Steps to Install OpenJDK 11 on macOS

datatec.studio
Java MVP
Published in
4 min readDec 26, 2022

--

This article will show you how to deinstall all preinstalled JDK from the mac OS and then install OpenJDK 11 on it. I used macOS Big Sur (11.7.2) as example.

TL;DR

sudo rm -fr /Users/yourUserName/Library/Java/JavaVirtualMachines/*
sudo rm -fr /Library/Java/JavaVirtualMachines/*
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install openjdk@11
sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk
java -version
  1. Deinstall all JDK
  2. Install OpenJDK 11 via brew
  3. Symlink JDK and check JDK version
  4. What’s Next

1. Deinstall all JDK

1.1 Firstly, execute followed command in Terminal to check if Java is installed on your laptop.

java -version

1.2 No JDK installed.
If the output of step 1.1 is something like the text followed, it means that there is no JDK installed in your system. You can then jump to step 2 “Install OpenJDK 11 via brew”.

The operation couldn’t be completed. Unable to locate a Java Runtime.

--

--