How To Install Java on Your New Java-less macOS

By mean “new” here is macOS Catalina & Big Sur. And I just finished (finally) fresh install my MacBook Pro with Big Sur 11.4. Bye Catalina.

As widely known, Oracle announced that the Oracle JDK 8 builds released after JAN 2019 will not be free for commercial use. Since OS X 10.7 Java is not (pre-)installed anymore. Well, I’m not a fan of Java myself (i stop using it after Java 1.6 i guess). But since I’m also tinkering with Android (and Kafka), I have no choice but put Java in my dev machines.

Instead using Oracle’s, I will use OpenJDK.

There are several ways to install OpenJDK to your Mac.

  1. Simply install the prebuilt OpenJDK binary.
  2. Install via homebrew
  3. Compile the source codes your self :P

Let’s use the easiest one. Option #1.

Adoptium is one of the best places to find prebuilt OpenJDK binaries. And as i write this article the lates LTS version is OpenJDK 11.0.12+7.
For you information, Adoptium previously was known as AdoptOpenJDK. The project’s goal was for providing the Java community with rock-solid runtimes and associated tools that can be used free of charge, without usage restrictions on a wide range of platforms. Later on, on June 2020 (cmiiw) AdoptOpenJDK moved to Eclipse Foundation and change the brand to Eclipse Adoptium Project.

  • Click on the OpenJDK installer as shown above. The installation window will appear and you just need to follow the instructions.
Installer’s welcome page
Software License Agreement
Finish installation
  • After finish, you need to verify the installation using command java -version
    It should be returning the information as shown below.
java version check
  • Almost done. Your Java base installation directory will be located in /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home and that should be the value of your JAVA_HOME environment variable. Don’t forget to put it in your ~/.zshrc or ~/.bash_profile file depending on whatever shell you’re using.
JAVA_HOME variable

That’s it. Done.