Installing JDK on macOS M1 (Apple Silicon)

Follow these steps to install the Java Development Kit (JDK) on a Mac with an M1 chip (Apple Silicon), based on Oracle’s official instructions.

Step 1: Download the JDK

  1. Visit Oracle’s official JDK download page.
  2. Select the macOS ARM 64 (AArch64) version, designed for M1/M2 chips. The file should be named like jdk-XX_macos-aarch64_bin.dmg (where XX is the version number).
    Installing JDK on macOS M1 (Apple Silicon) - Downloads Page
  3. Click on the link and the download should start.

Step 2: Install the JDK

  1. Locate the .dmg file in your Downloads folder.
  2. Double-click the .dmg file to open it. A Finder window will appear with a .pkg installer.
  3. Double-click the .pkg file to start the installation.
    Installing JDK on macOS M1 (Apple Silicon)
  4. Follow the installation prompts, clicking Continue where necessary.
  5. When prompted, click Install and enter your admin password to allow the installation.

After successful installation, you should get the following screen.

Close the window.

Step 3: Verify the Installation

Once the installation is complete, you can verify it by following these steps:

  1. Open the Terminal application.
  2. Run the following command to check the installed JDK version:
    java -version
  3. If everything is installed correctly, the terminal will display the version of Java you installed.
Verifying Java Installation

Step 4: Set JAVA_HOME (Optional)

If you need to set the JAVA_HOME environment variable for development purposes, you can follow these steps:

  1. Open your ~/.zshrc or ~/.bash_profile file in a text editor.
  2. Add the following line to the file:
    export JAVA_HOME=$(/usr/libexec/java_home)
  3. Save the file and run the following command in Terminal to apply the changes:
    source ~/.zshrc
    or
    source ~/.bash_profile

Step 5: Uninstalling the JDK (If Needed)

  1. Open Terminal.
  2. Run the following command to remove the JDK installation:
    sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-XX.jdk
  3. Replace XX with the version number you want to uninstall (e.g., jdk-21.jdk).

For more details, refer to the official Oracle documentation here.