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.
- Simply install the prebuilt OpenJDK binary.
- Install via homebrew
- 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.
- After finish, you need to verify the installation using command
It should be returning the information as shown below.
- Almost done. Your Java base installation directory will be located in
/Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Homeand that should be the value of your JAVA_HOME environment variable. Don’t forget to put it in your
~/.bash_profilefile depending on whatever shell you’re using.
That’s it. Done.