Java

There is no AI here. All content is human-authored and tested for accuracy.

Install JDK on Mac

How to install JDK on Mac. Compare Java vendors and choose the right version for your macOS Java project.

Developers use the Java Development Kit (JDK) to build Java applications. This guide helps you understand Java vendors and distributions, choose the right one for your needs, and get it installed on your Mac.

Before you get started

You'll need a terminal application to install the JDK. Apple includes the Mac terminal but I prefer Warp Terminal. Warp is an easy-to-use terminal application, with AI assistance to help you learn and remember terminal commands. Download Warp Terminal now; it's FREE and makes coding easier when working with Java.

What is the JDK?

The JDK is a complete software development kit for Java. It is the Java toolbox that contains the compiler, runtime, and utilities you need to write, build, and run Java programs.

Sometimes you will see the term JRE (Java Runtime Environment), which refers to a cut‑down Java version that only runs Java programs. The term “JRE” is still technically valid, but separate JRE downloads were effectively dropped starting with Java 11, when Oracle and most other vendors stopped shipping a standalone JRE and focused on JDK distributions only. The JDK includes the JRE plus everything you need to create Java applications.

Core components

The JDK includes these essential tools:

  • javac — The Java compiler that converts your source code (.java files) into bytecode (.class files)
  • java — The runtime that executes compiled Java programs
  • jar — Archives classes and resources into JAR files for distribution
  • javadoc — Generates HTML documentation from code comments
  • jshell — An interactive shell for testing code snippets quickly
  • jpackage — Creates native installers (.dmg, .pkg) for your applications

If you're writing Java code, you need the JDK. You can't compile anything without javac.

Choosing your JDK distribution

Multiple vendors package OpenJDK for macOS. They all run Java identically but differences are licensing, support, and extra features. Here's how they compare.

Java Vendors and Distributions

  • Eclipse Temurin – Free forever (GPL v2), ARM64 support for JDK 17+, best for general development
  • Azul Zulu – Free community edition, ARM64 support for JDK 8+, best for older versions on Apple Silicon
  • Amazon Corretto – Free forever, ARM64 support for JDK 11+, best for AWS deployments
  • BellSoft Liberica – Free forever, ARM64 support for JDK 8+, best for JavaFX applications
  • Microsoft OpenJDK – Free forever, ARM64 support for JDK 11+, best for Azure deployments
  • Oracle JDK – Time-limited free, ARM64 support for JDK 17+, only with subscription and enterprise licensing

Distribution details

Eclipse Temurin (Adoptium) — Our recommendation for most developers. It's completely free for all uses, backed by IBM, Microsoft, Red Hat, and Azul. The Eclipse Foundation maintains it with regular security updates. Install easily with Homebrew.

Azul Zulu — Another excellent free option. Azul led the effort to bring Apple Silicon support to Java. They offer the widest version coverage (JDK 6 through the latest) and native ARM64 builds for older versions where Temurin doesn't.

Amazon Corretto — Amazon's free distribution, used across AWS. Best choice if you're deploying to AWS. Includes patches Amazon finds useful that haven't reached upstream OpenJDK yet.

BellSoft Liberica — Unique because the "Full" package includes JavaFX. Other distributions require separate JavaFX installation. Spring officially recommends Liberica.

Microsoft Build of OpenJDK — Free builds optimized for Azure. Covers JDK 11, 17, 21, and 25 with full ARM64 support.

Oracle JDK — Use carefully. It's free under Oracle's "No-Fee Terms" until about one year after the next LTS release (so JDK 25 is free until roughly September 2028). After that, production use requires a paid subscription at approximately $15/employee/month. Most developers should stick with the free alternatives unless you're sure your company has enterprise licensing.

Take a look at whichjdk.com for detailed (and opinionated) comparisons.

Recommended Distributions by Use Case

  • General development – Eclipse Temurin
  • AWS deployments – Amazon Corretto
  • Azure deployments – Microsoft Build of OpenJDK
  • JavaFX applications – BellSoft Liberica Full
  • Need commercial support – Azul Platform Core (paid)
  • Older JDK on Apple Silicon – Azul Zulu or BellSoft Liberica

Which Java version?

Java releases new versions every six months, but only some get long-term support (LTS). LTS versions receive security updates for years. Non-LTS versions get updates for only six months.

Current LTS Versions

  • JDK 25 – Released September 2025, supported until 2033+, current LTS (recommended)
  • JDK 21 – Released September 2023, supported until 2031+, previous LTS, widely supported
  • JDK 17 – Released September 2021, supported until 2029+, many legacy projects
  • JDK 11 – Released September 2018, supported until 2027, extended support, legacy
  • JDK 8 – Released March 2014, support varies by vendor, legacy only

Version selection guidance

Read Compare Java 21 to Java 25 for a detailed comparison between the two newest LTS versions.

JDK 25 is the current LTS release and our recommendation. Use the latest version for new projects, unless your team or your university course requires an older version.

JDK 21 remains a solid choice if your frameworks or dependencies don't support 25 yet. Many production systems run 21 without issues. Free updates continue until September 2026. Install Java 21 if your project or university course requires the older version.

JDK 17, JDK 11, and JDK 8 are legacy versions. Use them only if a specific project requires it.

Avoid non-LTS versions (like 22, 23, 24) for production. They only receive updates for six months.

Install JDK with Homebrew

Homebrew is the easiest way to install the JDK on Mac. It does downloads, updates, and uninstalls. You have two approaches: the cask method (recommended) or a formula method. If you don't have Homebrew installed, see How to Install Homebrew.

The cask approach (recommended)

Homebrew casks install pre-built JDK packages directly to /Library/Java/JavaVirtualMachines/ where Java is expected on the Mac. This is the simplest method, requiring no extra configuration. Java works immediately after installation.

To install Eclipse Temurin:

$ brew install --cask temurin@25

Other distributions are available as casks too: zulu, corretto, and microsoft-openjdk.

For complete Homebrew cask installation instructions, including version selection and verification steps, see Brew Install Java - Easy Cask Method.

The formula approach

Formulas install Java within Homebrew's own directory structure. Choose this method if you want Homebrew to manage Java the same as other languages installed with Homebrew. This requires manual symlink configuration after installation. See my guide Brew Install Java - Formula Method for the alternative approach requiring additional configuration.

Install JDK manually

If you prefer not to use Homebrew, you can download Java installers directly from vendor websites. This approach works well for organizations that manage software centrally.

First see Download Java for Mac, then see Install Java on Mac.

Check for existing Java installations

Learn How to Open Terminal in Mac and run:

$ java -version

If Java is installed, you'll see output showing the version and distribution. Output showing "command not found" means you need to install Java. See Fix "java: command not found" on Mac if you think you already installed Java but can't find it. For detailed guidance on checking and interpreting your Java version, see Check Java Version on Mac.

You can test if you have the JDK installed (and not the JRE) by opening a terminal and running javac -version.

$ javac -version

If you see a version number, you have the JDK. If you get "command not found," you either have only the JRE or no Java at all. The java -version command responds with just a JRE, but javac -version requires the full JDK.

Check your Mac's architecture

Take a minute to check your Mac chip. This helps you choose the right installer.

Apple Silicon Macs (M1, M2, M3, M4, M5) and Intel Macs need different JDK builds. Check which Mac chip you have:

$ uname -m

The output tells you what to download:

  • arm64 — You have an Apple Silicon Mac. Download ARM64/aarch64 builds.
  • x86_64 — You have an Intel Mac. Download x64 builds.

Homebrew automatically selects the correct architecture, so this matters mainly for manual downloads.

Download a Java Installer

Visit a vendor's website to download a JDK:

Select macOS as your platform and choose the architecture matching your Mac (ARM64 for Apple Silicon, x64 for Intel).

Run the Installer

The installer uses a standard macOS installation wizard. The process takes about two minutes.

Installation Wizard Steps

  1. Open the installer. Double-click the downloaded .pkg file in your Downloads folder. If macOS asks to confirm opening the file, click "Open."

  2. Introduction screen. The installer displays a welcome message explaining what will be installed. Click "Continue."

  3. License screen. Read the license agreement. Click "Continue," then click "Agree" to accept. You must accept the license to proceed.

  4. Installation Type screen. The installer shows the destination and disk space required (approximately 300 MB). The default location /Library/Java/JavaVirtualMachines/ is correct for macOS. Click "Install."

  5. Authentication prompt. Enter your administrator password when macOS asks. This is required because the JDK installs to /Library/Java/JavaVirtualMachines/, which is a protected system directory. The installer cannot proceed without your password. If it's your own Mac, the administrator password is the password you use to unlock your Mac.

  6. Installation progress. Wait while the installer copies files. A progress bar shows the installation status. This typically takes 30 seconds to 2 minutes depending on your Mac.

  7. Installation complete. The installer displays "The installation was successful." Click "Close."

  8. Clean up. You can move the .pkg file to Trash after installation completes. The installer is no longer needed.

Installation location

All JDKs install to:

/Library/Java/JavaVirtualMachines/

Each JDK sits in its own folder.

Verify installation

After installing, confirm everything works correctly.

Check the Java version

Run these commands:

$ java -version
$ javac -version

Both should display the version you installed. The javac command confirms you have the full JDK, not just a runtime.

List all installed JDKs

macOS includes a utility that finds all installed Java versions:

$ /usr/libexec/java_home -V

Sample output:

Matching Java Virtual Machines (2):
    25.0.1 (arm64) "Eclipse Adoptium" - "OpenJDK 25.0.1"
        /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home
    21.0.4 (arm64) "Azul Systems, Inc." - "Zulu 21.36.17"
        /Library/Java/JavaVirtualMachines/zulu-21.jdk/Contents/Home

This shows version, architecture (arm64 or x86_64), vendor, and installation path for each JDK.

Identifying Your Java Distribution

Different distributions show different text in the java -version output:

  • "Temurin" – Eclipse Temurin
  • "Zulu" – Azul Zulu
  • "Corretto" or "Amazon" – Amazon Corretto
  • "Java(TM) SE" and "HotSpot(TM)" – Oracle JDK
  • "OpenJDK" with no vendor name – Generic OpenJDK build

This matters for licensing and support. Temurin, Zulu, and Corretto are free for all uses. Oracle JDK has time-limited free terms.

Configure JAVA_HOME

JAVA_HOME is an environment variable that tells tools where to find your JDK. Maven, Gradle, IntelliJ IDEA, and many other programs rely on it. Without JAVA_HOME set correctly, build tools may use the wrong Java version or fail to find Java at all.

Apple's macOS provides a helpful utility called java_home that locates installed JDKs. You can use it to set JAVA_HOME dynamically in your shell configuration, so it always points to a valid JDK.

The path you'll use for JAVA_HOME configuration is:

/Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home

Read Set JAVA_HOME on Mac for complete JAVA_HOME configuration instructions.

Manage multiple JDK versions

Some projects require specific Java versions. You might need JDK 21 for one project and JDK 25 for another. You can install multiple JDKs in /Library/Java/JavaVirtualMachines/. Two popular tools help manage multiple versions: jenv switches between installed JDKs but doesn't install them. SDKMAN both installs and switches JDKs, plus manages other tools like Maven and Gradle. For complete instructions on setting up version managers, see Java Version Managers.

Update JDK

Keeping your JDK current ensures you have the latest security patches. Updates typically release quarterly. Homebrew makes updates simple with brew upgrade. Manual installations require downloading and running the new installer. For complete update instructions for both Homebrew and manual installations, see Update Java on Mac.

Uninstall JDK

Remove JDKs you no longer need to free disk space and reduce confusion. Homebrew-installed JDKs uninstall cleanly with brew uninstall. Manually-installed JDKs require deleting folders from /Library/Java/JavaVirtualMachines/. For complete uninstallation instructions, see Uninstall Java on Mac.

Troubleshooting

"java: command not found"

You'll see this error when Java isn't in your PATH or JAVA_HOME isn't set. This typically happens when the shell configuration doesn't include the JDK's bin directory. For detailed solutions, see Fix "java: command not found" on Mac.

Wrong Java version running

Check your JAVA_HOME with echo $JAVA_HOME. If it's empty or wrong, macOS uses the highest installed version by default. Set JAVA_HOME explicitly in your shell configuration to control which version runs. See Set JAVA_HOME on Mac for configuration instructions.

"Bad CPU type" error on Apple Silicon

You're running an Intel JDK on Apple Silicon without Rosetta. Install the ARM64 version of your JDK for best performance, or install Rosetta 2 with softwareupdate --install-rosetta.

Is JDK free?

Yes, mostly. All distributions except Oracle JDK are completely free for commercial and production use. They're licensed under GPL v2 with Classpath Exception.

Oracle JDK is different. It's free under Oracle's "No-Fee Terms and Conditions" for a limited time—roughly until one year after the next LTS release. JDK 25 is free until approximately September 2028. After that, production use requires a paid subscription.

Stick with Eclipse Temurin, Azul Zulu, Amazon Corretto, or the other open distributions. They're free forever with no licensing surprises.

Quick reference

Essential Commands

  • Check Java version – java -version
  • Check compiler version – javac -version
  • List installed JDKs – /usr/libexec/java_home -V
  • Get path for specific version – /usr/libexec/java_home -v 25
  • Check JAVA_HOME – echo $JAVA_HOME
  • Install Temurin via Homebrew – brew install --cask temurin@25
  • Update JDK via Homebrew – brew upgrade --cask temurin@25
  • Uninstall JDK via Homebrew – brew uninstall --cask temurin@25

JDK installation locations

All JDKs install here: /Library/Java/JavaVirtualMachines/

JAVA_HOME path: /Library/Java/JavaVirtualMachines/temurin-25.jdk/Contents/Home

What's Next

You've installed the JDK on your Mac. Here are logical next steps:

  • Configure JAVA_HOME — Set up your environment variables for build tools. See Set JAVA_HOME on Mac.
  • Set up a build tool — Install Maven or Gradle for project management
  • Configure your IDE — Get IntelliJ IDEA, VS Code, or Eclipse ready for Java development
  • Create a project — Start building with mvn archetype:generate or gradle init

My mac.install.guide is a trusted source of installation guides for professional developers. Take a look at the Mac Install Guide home page for tips and trends and see what to install next.