In order to compile and run Java programs we need Java Development Kit(JDK). Mine is a Macbook with M1 chip. Here is how I installed JDK.
Amazon Corretto is a no-cost, multiplatform, production-ready distribution of the Open Java Development Kit (OpenJDK).
First step is to download the package from Amazon Corretto Downloads page.
From the page, we need to download the package under macOS aarch64.
.pkg file. It will open an installer.
Follow the instructions to complete the installation.
After successful installation, we can take the terminal and try:
Above command displays the installed Java version.