How to download and install Java on Mac

Macs don’t come with Java, and there is more than one place to get it: free OpenJDK builds such as Eclipse Temurin, or Oracle’s own JDK. Here is how to choose, how to install it and how to check that Terminal finds it.

Java

  • macOS 11 or later
  • Apple Silicon and Intel
  • Free (Eclipse Temurin)
Official Eclipse Temurin websiteadoptium.net ↗

Or the installer straight from the developer’s server:

The links go to the developer’s website (adoptium.net, api.adoptium.net). MacWashing is not affiliated with the developer and keeps no installers.

Open Terminal (Applications › Utilities) and run:

brew install --cask temurin

Homebrew downloads the app from the developer’s server, checks the file and puts the app in Applications.

No Homebrew yet? How to install Homebrew: one command from brew.sh.

SDKMAN! installs and switches JDKs from many vendors (Temurin, Zulu, Oracle and others). Install it with the command from its official site:

curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

Install the default JDK and check it. To see the other builds, run sdk list java:

sdk install java
java -version

Oracle JDK comes from Oracle’s download page oracle.com/java/technologies/downloads: pick the macOS tab and ARM64 DMG Installer for Apple Silicon or x64 DMG Installer for Intel. Open the .dmg and run the installer inside. With Homebrew it takes one command:

brew install --cask oracle-jdk@25
java -version

Before you use Oracle JDK at work, read the terms on the download page: it isn’t free forever (see «Which Java to download»).

Which Java to download

Java on a Mac means a JDK (Java Development Kit): it runs Java programs and builds them. Two common choices:

  • Eclipse Temurin from Adoptium (adoptium.net): a free, open-source build of OpenJDK, free for any use, at work too. The download buttons here give Java 25, the current long-term support (LTS) version.
  • Oracle JDK from oracle.com: Oracle’s own build. Oracle offers current versions such as JDK 25 at no cost, in production too, under its No-Fee Terms and Conditions until a year after the next LTS release. Later updates of that version come under a license that needs a paid subscription for business use.

Take an LTS version unless your project needs a newer one. Builds for Apple Silicon and Intel are separate: choose Apple menu › About This Mac. Chip with Apple M1 or later means Apple Silicon, Processor with Intel means Intel.

How to install Java

  1. Open the downloaded OpenJDK25U-jdk_…_mac_hotspot_….pkg in your Downloads folder.
The first screen of the Java installer
  1. Click Continue through the installer’s pages, accepting the license if asked, then click Install.
  2. Enter your Mac password. When the installer says the installation was successful, click Close.

The JDK goes to /Library/Java/JavaVirtualMachines. Several versions can sit there side by side. The java command uses the newest one unless you choose another.

What to set up after installing

Open a new Terminal window and check the version:

java -version
  • JAVA_HOME. Some tools need this variable. The command below adds it to your shell profile, so every new Terminal window has it.
  • Several versions. /usr/libexec/java_home -V lists every installed JDK.
  • Updates. The .pkg doesn’t update itself: download the newer one from the same page and install it. It replaces the old one of the same version.
  • The installer. Move the .pkg from Downloads to the Trash once the version check above works.
echo 'export JAVA_HOME=$(/usr/libexec/java_home)' >> ~/.zshrc

If Java won’t install or run

  • «Unable to locate a Java Runtime». macOS has a java command even without Java, and this is what it says when no JDK is installed. Install one as above and open a new Terminal window.
  • The wrong version runs. Check /usr/libexec/java_home -V and point JAVA_HOME at the version you need, for example /usr/libexec/java_home -v 21.
  • A broken or old JDK gets in the way. Remove it and install again: see how to uninstall Java on Mac.

Keep your Mac tidy

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

Java build tools keep caches that grow with every project. System Junk in MacWashing finds the caches apps and developer tools build up and shows how much space they take.

Free trial · macOS 14 or later

Questions and answers

Is Java free on Mac?

Eclipse Temurin is free for any use. Oracle JDK is free under Oracle’s No-Fee Terms for current versions, with limits for older updates. Read the license on Oracle’s download page before using it at work.

Do I need an Oracle account to download Java?

Not for Temurin: download it from adoptium.net or install it with Homebrew, no account needed. Oracle lists current JDK versions on its download page as direct downloads too.

Which Java does Homebrew install?

This command installs the newest Temurin release, which can be newer than the LTS: brew install --cask temurin For the LTS version, use: brew install --cask temurin@25