If you are using M1 Macbook or Mac mini computer, you must have noticed that Java from Oracle is not yet build for M1 Silicon chip yet! It only make use of Rosetta 2, you would see that the performance will take a hit.
Download Native Java JDK
Base on openJDK, azul provide the M1 native version of JDK. So, let’s download the installation package firstly.
Go to: https://www.azul.com/downloads/?package=jdk
Select Java Version: (8, 9, 10, 11, 12, 13, 14, 15)
Select Operating Sytem: macOS
Select Architecture: ARM-64
You will get links to download the setup as zip/dmg/tar.gz format - download anyone you prefer.
If you download the dmg package the installation is quite simple - Double click on Zulu.dmg file and on the popup click on “Double-Click to install Zulu X.x.x.x and follow the installation.
Open a terminal, execute the following command:
You may get the following information:
openjdk version "11.0.11" 2021-04-20 LTS
How to switch between different versions of Java
If you need use the different versions of Java in the same machine, you can install the different versions of Java, like Java 8 and Java 17. And you can switch them anytime easily. Specific methods can be referred to How to set JAVA_HOME in MacOS Big Sur