This post is a step-by-step guide for setting up Java Development Kit (JDK) on macOS operating system with version 20 of Oracle JDK, which is the commercial build of JDK by Oracle corporation.

You can use Oracle JDK for both personal, development and production use. Only businesses need to pay via Oracle’s Java SE subscription program. And JDK 20 is a regular update that was release on March 21st 2023. It’s not LTS (Long Term Support) release of Java SE platform.

 

1. Download DMG installer for Oracle JDK 20

For macOS, Oracle JDK is distributed in compressed archive file (.tar.gz) and installer (.dmg), and I recommend you choose DMG installer as it’s more convenient (few clicks to install without any manual configuration).

So head over to the Oracle JDK 20’s official download page, you’ll see the following page appears:

oracle jdk 20 download page macos

If your Mac computer running on Intel’s CPU, choose the download for x64 DMG Installer. Else choose ARM64 DMG Installer for Mac running on Apple’s CPU.

In my case, I’m using iMac with Apple M1 chip, so I click the link 1 for downloading DMG installer for Oracle JDK 20. It will download the jdk-20_macos-aarch64_bin.dmg file.

And it’s strongly recommended to check SHA256 checksum of the downloaded archive file to make sure it is safe to use (not tampered with). Open a new Terminal window. Change the current directory to location of the downloaded file, then type the following command:

shasum -a 256 jdk-20_macos-aarch64_bin.dmg



If the SHA256 checksum value printed by this command matches the one published on the download page (see the link number 2 in the above screenshot), it’s safe to continue.

 

2. Install Oracle JDK 20 on macOS

To install Oracle JDK 20 on macOS, double click the downloaded .dmg file. Then double click the extracted package JDK 20.0.1.pkg to run the installer. It will be something as below:

oracle jdk 20 installer macos

Click Continue and Install to start the installation. It should take just a few seconds. Then click Close to quit the installer. When you’re asked to move the installer to trash, let agree.

Oracle JDK 20 will be installed in the /Library/Java/JavaVirtualMachines/jdk-20.0.1.jdk directory. And it also puts java and javac programs under /usr/bin directory which is included in the PATH environment variable by default. So you don’t have to manually set JAVA_HOME.

Finally, type java -version and javac -version in the terminal to verify. You should see the following output:

oracle jdk 20 java version check

That means you have successfully installed Oracle JDK 20 on Mac computer. You can now begin running and developing Java applications on macOS operating system. You can also watch the following video to see the steps in action:

 

Related Articles:


About the Author:

is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.



Add comment