Below we use “17.0.x” to refer to some version of Java 17. The numbers might differ. Just download whatever the latest version is for Java 17.


Check whether you are on Apple Silicon or Intel

  1. Go to the Apple Menu » About This Mac.

    "Finding the About This Mac menu item"!

  2. Determine your Chip or Processor.

    • If you see Chip and/or you see “Apple” and not “Intel”, then you are on Apple Silicon.
    • If you see Processor and/or you see “Intel” instead of “Apple”, then you are using an Intel Mac.

    "Finding the About This Mac menu item"!

Install Java

Now, it is time to get Java for your Mac:

Apple Silicon

  1. Go to https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html to download Java SE Development Kit 17.0.x for macOS.

  2. Click on the download link for macOS Arm DMG Installer.

  3. Open the downloaded jdk-17.0.x_macos-aarch64_bin.dmg.

  4. Follow the instructions in the installer to complete the installation.

Intel

  1. Go to https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html to download Java SE Development Kit 17.0.x for macOS.

  2. Click on the download link for macOS x64 DMG Installer.

  3. Open the downloaded jdk-17.0.x_macos-x64_bin.dmg.

  4. Follow the instructions in the installer to complete the installation.

Set Up Environment Variables

For both Apple Silicon and Intel, the next step is to add environment variables. This allows the user to access Java command-line utilities from the terminal:

Launch the terminal. You can do this by searching for “Terminal” or “Terminal.app” in Spotlight Search. Alternatively, you can open Finder and go to Applications » Terminal.

Then, copy the following commands, paste them into the terminal window, and press Return or Enter:

touch ~/.zshenv
echo "export JAVA_HOME=\$(/usr/libexec/java_home)" >> ~/.zshenv
echo "export PATH=\$JAVA_HOME/bin:\$PATH" >> ~/.zshenv

Next, close and then reopen your terminal.

To check whether configuring the environment variables was successful, type the following in your newly-opened terminal window and press Return or Enter:

echo $JAVA_HOME

You should see something similar to /Library/Java/JavaVirtualMachines/jdk-17.0.x.jdk/Contents/Home.

Finally, check if Java is installed properly. Type the following in the terminal:

java -version

You should see something resembling:

java version "17.0.x" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.x+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.x+8-LTS-86, mixed mode, sharing)