Java on Mac Install: A Complete Step-by-Step Guide

Learn how to install Java on macOS with clear, actionable steps. Compare Oracle JDK vs OpenJDK, configure JAVA_HOME, verify installations, and manage multiple JDK versions for development on macOS.

Install Manual
Install Manual Team
·5 min read
Quick AnswerSteps

You will install Java on mac by choosing an OpenJDK or Oracle JDK distribution, downloading the installer, running it with admin access, and configuring environment variables. You'll verify the installation with java -version and optionally manage multiple JDKs using system tools. This guide covers macOS compatibility and common pitfalls.

What you will achieve with Java on macOS

By completing the steps in this guide, you will have a working Java development environment on your Mac. You’ll be able to compile and run Java programs from the terminal and inside your IDE. You’ll also learn how to choose between Oracle JDK and OpenJDK, configure system-wide environment variables, and manage multiple JDK versions if your projects require them. This article is designed for homeowners, DIY enthusiasts, and renters who want a reliable, repeatable process that minimizes surprises during installation. According to Install Manual, following a structured approach reduces setup time and prevents common configuration mistakes, especially on newer macOS releases where path and shell behavior can change.

Distribution choices: Oracle JDK vs OpenJDK

When you install Java on a Mac, you typically choose between Oracle JDK and OpenJDK distributions (commonly provided by Temurin, Adoptium, or similar projects). Oracle JDK tends to have a polished installer and consistent licensing for enterprise use, while OpenJDK builds are often favored by developers for their permissive licenses and rapid release cadence. Your choice should depend on licensing requirements, compatibility with your IDE and build tools, and whether you require long-term support (LTS). This section outlines the trade-offs and helps you decide which path best fits your workflow. Install Manual notes that many developers opt for Temurin (OpenJDK) for day-to-day development and switch to Oracle JDK only when a specific application calls for it.

System requirements and macOS compatibility

Most modern macOS versions support both Oracle JDK and OpenJDK builds. Confirm your macOS version is supported by the JDK you plan to install, especially if you’re on an older release or an Apple Silicon Mac. You should also verify disk space (a few hundred megabytes for the JDK) and ensure you have administrator privileges to install system-wide software. If you rely on a corporate network or proxy, configure your network settings as needed before downloading installers. Install Manual analysis shows that almost all macOS installations succeed when users follow the official installer prompts and avoid downloading from third-party sources.

Manual installation: Oracle/OpenJDK installers (PKG/DMG)

Manual installation involves downloading the official macOS installer package (PKG or DMG), opening it, and following the on-screen prompts. You will typically accept license terms, select an installation destination, and provide your administrator password to authorize system changes. The installer places the JDK in /Library/Java/JavaVirtualMachines, registering it with macOS so command-line tools like java and javac are available. If you encounter permission prompts, ensure you’re using an administrator account and that your disk isn’t full.

Using Homebrew to install Java (optional but convenient)

Homebrew offers a straightforward alternative for macOS users who prefer a package manager. If you already have Homebrew, you can install a Java distribution via a Cask, such as Temurin, with commands like brew update followed by brew install --cask temurin. Homebrew handles architecture differences and updates, making it a good option for quick setups or when you regularly switch Java versions. If you don’t have Homebrew, you can still install Java using the manual method described above.

Post-install configuration: JAVA_HOME and PATH (macOS shells)

After installation, you’ll typically set JAVA_HOME to the active JDK and ensure the Java binaries are on your PATH. The macOS utility /usr/libexec/java_home can detect the current default JDK and return its path. A common approach is to add lines to your shell profile (e.g., ~/.zshrc or ~/.bash_profile):

  • export JAVA_HOME=$(/usr/libexec/java_home)
  • export PATH="$JAVA_HOME/bin:$PATH"

Reload your profile or start a new terminal session for changes to take effect. This step ensures that java, javac, and other tools resolve to the intended JDK version.

Verifying the installation and troubleshooting basics

Open Terminal and run java -version and javac -version to confirm the JDK is active. If you see an error or the command isn’t found, review your PATH and JAVA_HOME settings, and ensure there aren’t conflicting Java installations on your system. If you’re on Apple Silicon, verify that you installed an ARM64 build or universal binary. Restarting the terminal or the computer can resolve path caching issues and finalize environment variable changes.

Managing multiple JDK versions on macOS (switching between versions)

Professionals often need to switch between JDK versions for different projects. Use /usr/libexec/java_home -v to list installed versions and to set JAVA_HOME to a specific version (for example, export JAVA_HOME=$(/usr/libexec/java_home -v 11)). You can also use tools like jenv to simplify switching. After changing JAVA_HOME, run java -version to verify the active version and ensure your IDE reflects the correct JDK.

Troubleshooting common problems and best practices

If you encounter issues, confirm you downloaded from the official sources and that your macOS firewall or network policy isn’t blocking the installer. Ensure you have modern shell configuration (zsh by default on macOS Catalina and later) and that you edited the correct profile file. For Apple Silicon Macs, use ARM64 builds or universal binaries and verify compatibility with your development tools. Finally, keep your JDK up to date and review security advisories to maintain a secure development environment.

Tools & Materials

  • Admin access on macOS(You will be prompted for your password during installation)
  • Active internet connection(Needed to download installers from official sources)
  • Terminal app(Used for commands and environment setup)
  • Java installer (Oracle JDK or OpenJDK/Temurin)(Download from official source (Oracle or Temurin/OpenJDK))
  • macOS user account with administrator privileges(Needed to install system-wide software)
  • Homebrew (optional)(If you prefer using a package manager to install Java)
  • Text editor or shell editor(Helpful for editing shell profiles (e.g., ~/.zshrc))

Steps

Estimated time: Estimated total time: 20-40 minutes

  1. 1

    Decide distribution

    Evaluate whether Oracle JDK or an OpenJDK build (like Temurin) is best for your needs. Consider licensing, support, and compatibility with your IDE and build tools. This decision impacts update cadence and long-term stability for your projects.

    Tip: Point to your primary development toolchain and verify compatibility notes from the vendor.
  2. 2

    Download the official installer

    Visit the official Oracle JDK or Temurin/OpenJDK page and download the macOS installer (.pkg or .dmg). Confirm your macOS version and architecture (Intel or Apple Silicon) before downloading. Always download from the official source to avoid malware.

    Tip: Bookmark the official download page for quick future access.
  3. 3

    Run the installer

    Open the downloaded installer and follow the prompts. You’ll likely accept terms, select a destination, and enter your admin password to authorize installation. The installer will place the JDK under /Library/Java/JavaVirtualMachines.

    Tip: Keep the installer window open in case you need to re-run it for any reason.
  4. 4

    Locate the installed JDK

    Verify the JDK presence by listing the JavaVirtualMachines directory. You should see a folder with a .jdk extension corresponding to the version you installed. This confirmation helps avoid path-related confusion later.

    Tip: If you don’t see the folder, re-run the installer or check for errors in the installation log.
  5. 5

    Configure JAVA_HOME

    Set JAVA_HOME using macOS’s java_home utility, which adapts to the active JDK. Add export JAVA_HOME=$(/usr/libexec/java_home) to your shell profile so future terminals inherit the setting.

    Tip: Using /usr/libexec/java_home keeps JAVA_HOME current after system upgrades.
  6. 6

    Update PATH

    Ensure the JDK bin directory is on your PATH. Add export PATH="${JAVA_HOME}/bin:$PATH" to your shell profile and reload the profile or start a new terminal session.

    Tip: Place this early in your PATH so other toolchains (like Maven or Gradle) find the correct java tools first.
  7. 7

    Verify the install

    Run java -version and javac -version to confirm the compiler and runtime are accessible. If you see a mismatch, revisit your JAVA_HOME and PATH settings and ensure there aren’t conflicting installations.

    Tip: If Java isn’t found, run which java to locate the binary and adjust PATH accordingly.
  8. 8

    Manage multiple JDK versions

    If you work with multiple Java versions, list installed JVMs with /usr/libexec/java_home -V and switch by exporting JAVA_HOME to a specific version. IDEs can also be configured to use a particular JDK.

    Tip: Test each version with java -version after switching to confirm the intended JDK is active.
Pro Tip: Always download Java from official sources to avoid malware and tampered installers.
Warning: Do not mix installers from untrusted sites; this can introduce security risks or broken configurations.
Note: On Apple Silicon, prefer ARM64 builds or universal binaries for optimal performance.

Got Questions?

Do I need admin rights to install Java on macOS?

Yes. Installing or updating system-wide software typically requires administrator privileges. You’ll be prompted to enter your password during the installer process.

Admin rights are required to install Java on macOS. You’ll be prompted to enter your password during installation.

Which Java distribution should I choose for mac development?

OpenJDK distributions like Temurin are widely used for development due to flexible licensing and broad tool support. Oracle JDK is a solid choice when you need Oracle licensing guarantees or enterprise features. Choose based on licensing, support, and project requirements.

OpenJDK like Temurin is common for development; Oracle JDK is good for projects needing Oracle licensing.

How do I switch between multiple JDK versions on Mac?

List installed JDKs with /usr/libexec/java_home -V and set JAVA_HOME to the desired version. You can also use tools like jenv for easier switching and IDE configuration.

Use java_home to switch versions or a tool like jenv for easier management.

Can I install Java on Apple Silicon Macs without compatibility issues?

Yes. Most modern JDK distributions provide ARM64 builds or universal binaries compatible with Apple Silicon. If you encounter issues, verify you installed a 64-bit JDK and check your IDE settings.

Yes, Apple Silicon Macs are supported with ARM64 or universal builds.

What should I do if Java isn’t found after installation?

Check that JAVA_HOME and PATH are set correctly and that you’re using the correct shell profile. Ensure there are no conflicting Java installations that could override your settings.

Review JAVA_HOME and PATH, and verify there aren't conflicting installs.

Is Java always required for every macOS project?

Not all projects require Java. If your development involves other languages or environments, you can install a JDK as needed and manage versions per project. Use lightweight tooling when Java is only occasional.

No—only install Java if your projects require it; you can manage versions per project.

Watch Video

Main Points

  • Choose the right Java distribution for licensing and compatibility
  • Install from official sources and verify the installer
  • Configure JAVA_HOME and PATH correctly for reliable CLI access
  • Use system tools to manage and switch between multiple JDK versions
Process flow for installing Java on macOS
3-step Java installation on Mac: download, install, verify

Related Articles