How to Download Java on Mac: Official Sources

Download Java on Mac from an official source: adoptium.net (Temurin), Homebrew, or Amazon Corretto. Pick the architecture that matches your Mac: aarch64 for Apple Silicon (M1/M2/M3/M4), x64 for Intel.

Check your Mac architecture first

uname -m
  • arm64 — Apple Silicon: download aarch64 builds
  • x86_64 — Intel: download x64 builds

Option A: Homebrew (easiest, keeps up to date)

brew install openjdk@21

Homebrew automatically picks the right architecture. After install, run the symlink command printed by brew and add JAVA_HOME to ~/.zshrc.

Option B: Adoptium Temurin .pkg

  1. Open adoptium.net in your browser.
  2. Click Other platforms and versions if you need a specific version.
  3. Choose macOS and the correct architecture, then click Download JDK.
  4. Open the downloaded .pkg — follow the install wizard.
  5. The JDK is installed to /Library/Java/JavaVirtualMachines/temurin-21.jdk.
  6. Open a new Terminal: java -version.

Option C: Amazon Corretto

  1. Go to aws.amazon.com/corretto.
  2. Choose Java 21 (or 17), then macOS, then the correct architecture.
  3. Download the .pkg and install it.

After downloading: set JAVA_HOME

macOS does not always set JAVA_HOME automatically from a .pkg install. Add this to ~/.zshrc:

export JAVA_HOME=$(/usr/libexec/java_home -v 21)

Then reload: source ~/.zshrc and verify: echo $JAVA_HOME.

Verify

java -version
javac -version

javac is the compiler and only exists in the JDK. If javac fails, you downloaded a JRE build — go back and download the JDK.