Java

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

Java on Mac

Complete guide to Java on macOS. How to install Java, pick the right JDK, manage multiple versions, and configure Java for use on your Mac.

Java is one of the most widely used programming languages, especially in large enterprises and university courses. Until 2012, Apple included Java with macOS. Now you need to install it yourself which is confusing, with multiple vendors and versions. These Mac Install Guide tutorials cover every aspect of Java installation on Mac.

My guides show the best approach, using the command line, with recommendations for the best Java source and version.

Before you get started

You'll need a terminal application to develop with Java on your Mac. 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's Covered Here

The easiest way to get started is with a Homebrew installation of Java:

If you don't want to use Homebrew, you can manually install Java:

Configure a development environment:

Java 25 is the latest version:

If you need to troubleshoot, update, or uninstall:

Read on for an overview of the important topics, with links to in-depth articles.

What's a JDK?

A JDK (Java Development Kit) contains everything needed to develop and run Java applications. It includes a JRE (Java Runtime Environment), which provides the JVM (Java Virtual Machine) and standard libraries required to run Java programs, plus tools like javac (the compiler), javadoc (a documentation generator), jar (for building and unpacking JAR files), debuggers, and other development utilities.

Sun Microsystems created the Java language and the JVM in the early 1990s. In 2010, Oracle acquired Sun Microsystems and the Java platform, and today multiple vendors besides Oracle produce JDK distributions based on the open Java SE specifications, incuding OpenJDK builds and vendor distributions derived from them. To develop Java applications, you'll install a JDK.

Install Java with Homebrew

Homebrew (the Mac software package manager) is the fastest way to install Java on Mac. Use one command to download, install, and configure Java. Homebrew offers two methods: casks use the standard macOS location and work immediately; formulas use Homebrew's directory and require a symlink. Two guides explain all the details.

Brew Install Java - Easy Cask Method — Install Java with brew install --cask temurin@25. The cask places Java in /Library/Java/JavaVirtualMachines/ where macOS finds it automatically. No additional configuration needed. The guide explains why the cask method is the easiest and helps you decide if the alternative formula method might be better for you.

Alternative approaches:

  • Brew Install Java - Formula Method — Install OpenJDK to Homebrew's Cellar with brew install openjdk@25. This method requires creating a symlink so macOS can detect the installation.

Install Java Manually

If you don't use Homebrew, you face one important preliminary question: how do I get Java onto my Mac? JDK distributions are available from multiple vendors and can be installed as Mac PKGs with a graphical installer. The free Eclipse Temurin is our recommended distribution.

Install Java on Mac — Start here for a complete walkthrough using an installer. This guide covers system requirements, the installation wizard, and verification steps.

Related guides (for more detail):

  • Download Java for Mac — Detailed guidance comparing JDK distributions from various vendors (Temurin, Zulu, Corretto, Oracle) and how pick a Java version and where to obtain a JDK
  • Install JDK on Mac — How to run an installer and configure the development environment
  • Install OpenJDK on Mac — Learn what OpenJDK is, why it's the standard, and what TCK certification means for compatibility
  • Install Java 25 on Mac — Java 25 is the current LTS (Long-Term Support) release, recommended for new projects
  • Install Java 21 on Mac — Java 21 is the previous LTS version for projects that require it
  • Compare Java 21 to Java 25 — Detailed comparison between the two newest LTS versions

Verify Your Installation

If you've just installed Java, or you're starting a new project or troubleshooting, confirm the Java version that you have installed. The java -version command shows your current version. This guide helps you understand the output: version numbers, vendor strings, and architecture.

Check Java Version on Mac — Learn to run java -version and javac -version, interpret the three-line output, identify your distribution from vendor strings, and list all installed JDKs with /usr/libexec/java_home -V.

Related guides:

Configure the macOS Environment

After installing Java, you may need to configure environment variables so build tools and IDEs can find it. The JAVA_HOME variable tells tools where Java lives. The PATH variable determines which java command runs when you type it in Terminal.

Set JAVA_HOME on Mac — Configure JAVA_HOME using Apple's /usr/libexec/java_home utility. This guide covers permanent configuration in the zsh shell, version-specific settings, and troubleshooting common errors.

Related guides:

  • Set Java PATH on Mac — Configure PATH so Terminal finds Java commands from any directory. Covers which java, shell command hashing, and diagnosing wrong-version issues.
  • Unable to Locate a Java Runtime — When Java is installed but the shell cannot find it

Switch Among Java Versions

If you've got more than one project, you'll need to switch among different Java versions. A legacy application might need Java 8 while new development uses Java 25. Version managers automate switching between JDKs so you don't have to edit environment variables manually.

Java Version Managers — Compare SDKMAN, mise, jEnv, Jabba, asdf, and manual switching. SDKMAN is recommended for JVM-focused developers; mise is preferred by developers who use multiple languages.

Related guides:

Java on Apple Silicon

Java predates the Apple M1, M2, M3, M4, M5 chip series (ARM64 processors), dating from the days when Apple used Intel chips. Now Macs use Apple Silicon and Java has a native ARM64 version that runs significantly faster than the Intel Java version. All major distributions now provide ARM64 builds for Java 11 and later; if your (old) project needs Java 8, there's fewer choices of vendors.

Java on Apple Silicon or Intel Macs — Where to get a Java distribution for older Intel Macs or Java 8 for an Apple Silicon Mac.

Maintain Java Over Time

MacOS does not update Java automatically, so you need to check for updates and apply them yourself (especially Java's' quarterly security updates). When you no longer need a Java version, removing it completely requires deleting files from hard-to-find locations.

Update Java on Mac — Get security patches via Homebrew or manual download. Covers the difference between patch updates and major upgrades, and recommended update frequency.

Related guides:

  • Uninstall Java on Mac — Remove JDKs completely, including Oracle-specific components, Homebrew packages, and version manager installations
  • Java Latest Version — More information about the newest Java release

Java Development Tools

Java developers rely on a broader ecosystem of tools beyond the JDK itself. Build tools automate compilation and manage dependencies, version control provides save-as-you-go safely tracking your code history, and IDEs provide an editor where you write and debug code.

Build Tools and Dependency Management

Build tools automate compilation, testing, and packaging while managing project dependencies, so you can use programming libraries without coding everything from scratch.

  • Maven — Apache Maven uses XML-based configuration (pom.xml) to define project structure, dependencies, and build lifecycle. Maven follows a "convention over configuration" philosophy and automatically fetches dependencies from central repositories.

  • Gradle — Gradle offers a more flexible alternative to Maven, using Groovy or Kotlin DSL (domain specific languages) for build scripts. The tool is good at incremental builds and popular for Android development.

Version Control Systems

Version control tracks changes, enables collaboration, and maintains code history so you can "save as you go" and safely rollback to earlier work when you make mistakes.

  • Git — Git operates as a distributed version control system, allowing multiple developers to work on projects without overwriting each other's work. You create snapshots of your work and can revert to previous versions easily. We've got a guide so you can get started with Git.

  • GitHub and GitLab — These cloud-based platforms built on Git provide repository hosting, issue tracking, and project management tools for collaboration. Microsoft's GitHub is the largest platform for open-source collaboration, and GitLab is a popular alternative. We've got a guide for setting up Git for GitHub.

Integrated Development Environments (IDEs)

An IDE provides code editing, debugging, and project management in a single application. Developers using dynamic languages such as JavaScript, Python, or Ruby typically use simpler code editors such as VS Code but Java developers prefer the power of a fully featured IDE.

  • IntelliJ IDEA — JetBrains IntelliJ dominates the Java landscape with smart code completion, advanced refactoring tools, and native Git integration. The IDE offers a free Community Edition and an Ultimate Edition with enterprise features.

  • Eclipse — The Apache Foundation maintains Eclipse as an open-source platform with over 1,250 plugins available. Eclipse is popular in academic settings.

  • NetBeans — Apache NetBeans offers built-in support for Java SE, JavaFX, and web technologies with a straightforward, beginner-friendly environment. The IDE provides consistent performance and simplicity without extensive configuration.

  • Visual Studio Code — Microsoft's VS Code has emerged as a lightweight alternative for Java development, especially for developers working with multiple languages. VS Code works well for small projects and when you need a fast, extensible editor.

Spring Framework and Spring Boot

The Spring ecosystem dominates Java application development for enterprise and cloud-native applications.

  • Spring Boot — Spring Boot simplifies application development by eliminating boilerplate configuration and providing opinionated defaults. The framework includes the Tomcat embedded server, letting you run applications as standalone JARs without external server setup.

  • Spring Cloud — Spring Cloud extends Spring Boot with microservices patterns like service discovery, configuration management, and circuit breakers. It integrates seamlessly with cloud platforms including AWS, Azure, and Google Cloud Platform.

Microservices Frameworks

Microservices frameworks provide tools and patterns for building distributed, independently deployable services. Large Java enterprise projects typically use a microservices architecture; you're not likely to use microservices for classroom projects.

  • Spring Boot — Spring Boot is most popular with its mature ecosystem, extensive documentation, and integration with all major cloud platforms. The framework is used mostly for its ecosystem depth and enterprise features rather than raw performance.

  • Quarkus — Quarkus is designed specifically for cloud-native and containerized applications with Kubernetes-first architecture. It achieves lightning-fast startup times and low memory consumption through ahead-of-time compilation with GraalVM.

  • Micronaut — Created by the Grails team, Micronaut optimizes at compilation time rather than runtime, resulting in faster startup and lower memory usage. The framework provides built-in HTTP servers, cloud-native features, and excellent support for service discovery.

Troubleshooting

The most common Java problem on Mac is the "command not found" error. This happens when Java is not installed, not in your PATH, or your shell configuration has not loaded. Other issues include the wrong version running or build tools failing to find Java.

Unable to Locate a Java Runtime — Diagnose whether Java is installed, configure PATH correctly, and resolve shell configuration issues. Covers zsh with specific solutions for each root cause.

Related guides:

Recommended Reading Paths

New to Java on Mac

  1. Brew Install Java - Cask Method or Install Java on Mac
  2. Check Java Version on Mac
  3. Set JAVA_HOME on Mac

Troubleshooting Existing Java

  1. Unable to Locate a Java Runtime
  2. Set JAVA_HOME on Mac
  3. Check Java Version on Mac

Managing Multiple Versions

  1. Java Version Managers
  2. Install SDKMAN for Java on Mac
  3. Set JAVA_HOME on Mac

Choosing the Right Version

  1. Java Latest Version
  2. Compare Java 21 to Java 25
  3. Install Java 25 on Mac

Quick Reference

Essential Commands

# Check Java version
$ java -version

# Check compiler version
$ javac -version

# List all installed JDKs
$ /usr/libexec/java_home -V

# Check JAVA_HOME
$ echo $JAVA_HOME

# Install Java via Homebrew (recommended)
$ brew install --cask temurin@25

# Update Java via Homebrew
$ brew upgrade --cask temurin@25

Key Paths

  • /Library/Java/JavaVirtualMachines/ – Standard JDK installation directory
  • /usr/libexec/java_home – macOS utility for finding JDKs
  • ~/.zprofile – Shell configuration for JAVA_HOME and PATH
  • /opt/homebrew/ – Homebrew directory on Apple Silicon
  • /usr/local/ – Homebrew directory on Intel Macs

What's Next

Most developers should begin with Install Java on Mac or Brew Install Java - Cask Method for the fastest path to a working installation. If you're troubleshooting, Unable to Locate a Java Runtime addresses the most common error. For new projects, Install Java 25 on Mac covers the current LTS release.

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.