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: downloadaarch64buildsx86_64— Intel: downloadx64builds
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
- Open adoptium.net in your browser.
- Click Other platforms and versions if you need a specific version.
- Choose macOS and the correct architecture, then click Download JDK.
- Open the downloaded
.pkg— follow the install wizard. - The JDK is installed to
/Library/Java/JavaVirtualMachines/temurin-21.jdk. - Open a new Terminal:
java -version.
Option C: Amazon Corretto
- Go to aws.amazon.com/corretto.
- Choose Java 21 (or 17), then macOS, then the correct architecture.
- Download the
.pkgand 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.