3 Steps to Install OpenJDK 11 on macOS

<p>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.</p> <p>TL;DR</p> <pre> sudo rm -fr /Users/yourUserName/Library/Java/JavaVirtualMachines/* sudo rm -fr /Library/Java/JavaVirtualMachines/* /bin/bash -c &quot;$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)&quot; brew install openjdk@11 sudo ln -sfn /usr/local/opt/openjdk@11/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-11.jdk java -version</pre> <ol> <li><strong><em>Deinstall all JDK</em></strong></li> <li><strong><em>Install OpenJDK 11 via brew</em></strong></li> <li><strong><em>Symlink JDK and check JDK version</em></strong></li> <li>What&rsquo;s Next</li> </ol> <h2>1. Deinstall all JDK</h2> <p>1.1 Firstly, execute followed command in Terminal to check if Java is installed on your laptop.</p> <pre> java -version</pre> <p>1.2 No JDK installed.<br /> 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 &ldquo;Install OpenJDK 11 via brew&rdquo;.</p> <p><a href="https://medium.com/java-mvp/3-steps-to-install-openjdk-11-on-macos-3ae0e10dfa1a"><strong>Visit Now</strong></a></p>