Follow the steps below to setup Java development environment on Mac operating system - the first step to get started creating, developing and running Java applications on Apple computers.

You know, JDK or Java Development Kit is a set of software programs and libraries that are necessary to compile, build and run Java programs. And JDK 22 is a regular update which was released on March 19th 2024.

Oracle JDK is a commercial distribution of JDK provided by Oracle corporation - the steward of Java technologies. It’s free for personal, development and production use.

 

1. Download macOS Installer for Oracle JDK 22

For macOS, Oracle JDK is distributed as compressed archive (.tar.gz) as well as DMG installer. It’s recommended to use DMG installer as it’s quick, easy and convenient to setup Java 22 for macOS.

Click this link to visit the official Java downloads page for macOS. You will see the following files available for download:

Oracle JDK 22 Downloads macOS

There are two types of DMG installer:

  • ARM64 DMG Installer: this is for Mac computers running on Apple CPU (Apple Silicon), typically new or recent Macs
  • x64 DMG Installer: this is for Macs equipped with Intel CPU, which are older
You can check whether your Mac has Apple or Intel CPU by clicking the apple icon > About this mac.



For example, my Mac running on Apple M1 chip so I click the download link (1) next to ARM64 DMG Installer file type.


2. Verify Installer File

Do not run the installer right after download. It’s strongly recommended to verify the integrity of the downloaded file before opening it. On the download page you can see the sha256 link (2) next to the download link (1). Click and it will show the SHA256 checksum value of the original file.

Now open a new Terminal window, change the current directory to where the downloaded file is saved. Then type the following command:

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

this prints the SHA256 checksum value of the specified file. Then compare it against the one provided in the sha256 link above. If both are the same, that means the downloaded file was not tampered with and you can open it safely.

 

3. Run Oracle JDK 22 macOS Installer

Double click the installer file. Then double click JDK 22.pkg package to start the setup of Java 22 on macOS with Oracle JDK distribution. The JDK 22 installer program appears as shown below:

oracle jdk 22 setup program

Click Continue two times, then click Install to proceed Java 22 setup on macOS with default installation location. You need to provide administrator password to install the software. The setup will run very quick. Finally, it says “Install Succeeded”. Click Close to quit the installer.

 

4. Verify Oracle JDK 22 Installation on macOS

Using DMG installer, you don’t have to manually configure environment variables as it puts the java and javac executables under /usr/bin folder which is included in the PATH variable by default. The default installation directory is /Library/Java/JavaVirtualMachines/jdk-22.0.1.jdk.

To verify Oracle JDK 22 setup on macOS, open a new Terminal window and type java -version and javac -version commands. You should see the following output:

verify oracle jdk 22 installation

That means Java 22 has been successfully installed on macOS with Oracle JDK distribution. You now can start developing and running Java applications on Mac computers.

To see the setup of Oracle JDK 22 on Mac in action, watch the following video:

 

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