Java

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

Install Java 25 on Mac

How to install Java 25 on Mac step by step. Get the free Java 25 JDK for macOS, install with Homebrew or a PKG, verify the version, and set JAVA_HOME.

Java 25 is the latest Java version, released in September 2025. As a long-term support (LTS) release, Java 25 will receive security updates and bug fixes until at least 2033. This guide explains why it is the best choice for new projects and walks you through options for installing Java 25 on your Mac.

If you're taking a university course or working on a software engineering team, before you install or upgrade to Java 25, check with your instructors or project lead for course or team requirements. Existing software projects or university courses may reuire Java 21, the most recent long-term support (LTS) release, or an even older version of Java. However, for new projects, developers should install Java 25.

Before you get started

You'll need a terminal application to develop with Java 25. 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.

Why Java 25?

Java 25 brings meaningful improvements that make it worth upgrading. In some ways, particularly the new simplified main method construction, it's a major leap forward and you'll notice the difference between Java 25 and Java 21 code.

Compact source files and simplified main methods

Java 25 introduces compact source files, a simplified form of source file that lets you write small programs without an explicit class declaration or public static void main(String[] args). The traditional "Hello World" required a class declaration, public access modifier, static modifier, and a String array parameter. Java 25 simplifies this to:

void main() {
    IO.println("Hello, World!");
}

The new IO class in java.lang provides print(), println(), and readln() methods without imports. Compact source files get special treatment with modules and imports. In compact source files, Java 25 makes all of java.base available by default, so common types like List, Map, and Stream work without individual import statements. This is especially useful for scripting, prototyping, and teaching. While Java won't replace dynamic Python, Ruby, or Perl for scripting, Java is now a legitimate choice for simple script utility tasks.

Flexible constructor bodies

Java 25 allows statements before super() or this() calls in constructors. Previously, calling the parent constructor had to be the first statement, forcing awkward workarounds for parameter validation:

class Employee extends Person {
    Employee(int age) {
        if (age < 18 || age > 67)  // Now allowed before super()
            throw new IllegalArgumentException("Invalid age");
        super(age);
    }
}

Scoped values for virtual threads

Scoped values provide a safer, more efficient alternative to thread-local variables. They're immutable, automatically cleaned up, and optimized for virtual threads. This makes concurrent code simpler and less prone to memory leaks:

public static final ScopedValue<String> USER = ScopedValue.newInstance();

ScopedValue.where(USER, "admin").run(() -> {
    // USER.get() returns "admin" here
    processRequest();
});

Performance improvements

Java 25 delivers significant performance gains without code changes:

  • Compact object headers reduce memory overhead from 12 bytes to 8 bytes per object, saving roughly 10-20% heap space for object-heavy applications
  • Generational Shenandoah Garbage Collection is a a low‑pause Java garbage collector that now uses generational collection, improving pause times for latency-sensitive applications
  • Ahead-of-time method profiling speeds up application startup by preserving JIT compiler data between runs

LTS stability

As a long-term support release, Java 25 comes with eight years of Oracle long‑term support, including quarterly security and performance updates. Oracle provides free JDK 25 updates under the No‑Fee Terms and Conditions (NFTC) license until at least September 2028, with paid commercial support and updates available through September 2033. Many OpenJDK vendors also treat Java 25 as an LTS and offer multi‑year maintenance in line with their own policies. This makes Java 25 a solid choice for production deployments that need a stable baseline and predictable updates rather than frequent upgrades.

Upgrading from older Java versions

See the guide Update Java on Mac.

If you're upgrading an existing project, here's what to expect.

From Java 21

This is the smoothest upgrade path. Most Java 21 code runs on 25 without changes. Watch for:

  • Annotation processing now disabled by default (use -proc:full if needed)
  • Security Manager permanently removed
  • Some internal APIs further restricted

From Java 17

If you're upgrading from Java 17:

  • UTF-8 is now the default charset (was system-dependent)
  • Strong encapsulation of JDK internals may require --add-opens flags
  • Dynamic agent loading requires explicit permission

From Java 11

With Java 11, significant migration effort is required:

  • Module system (JPMS) encapsulates internal APIs
  • javax.* packages moved to jakarta.* for Jakarta EE
  • Removed: JavaFX (now separate), Nashorn, Java Web Start, Applet API

Consider migrating in stages (11 → 17 → 21 → 25) or use OpenRewrite for automated migration recipes.

Framework compatibility

Spring Boot 4.x requires Java 17 minimum and works great with Java 25. If you're on Spring Boot 2.x with Java 8, you'll need to upgrade both the framework and Java together.

  • Spring Boot 4.x – Minimum Java 17, full support for Java 25
  • Spring Framework 7.x – Minimum Java 17, full support for Java 25
  • Quarkus 3.x – Minimum Java 17, full support for Java 25
  • Micronaut 4.x – Minimum Java 17, full support for Java 25
  • Jakarta EE 11 – Minimum Java 17, full support for Java 25

Build tools need updates too. Use Maven 3.9.0+ and Gradle 9.0+ for full Java 25 support.

Check Java Version

Check whether you already have Java installed. 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.

Install Java 25 on Mac

Choose a Java distribution

Several organizations provide Java 25 builds. All are based on the OpenJDK specification and functionally identical. The differences are licensing and support.

Eclipse Temurin is recommended by most developers. It's completely free, backed by the Eclipse Foundation, and receives quarterly security updates. Read Install JDK on Mac for a complete comparison of Java distributions, if you'd like to consider another choice.

Install Java 25 with Homebrew

Homebrew is the easiest way to install Java 25. It handles architecture detection, installs to the correct location, and registers Java with macOS automatically. We've got a guide How to Install Homebrew.

Read Brew Install Java - Easy Cask Method for detailed Java 25 installation instructions with Homebrew. Here's the basics:

$ brew update
$ brew install --cask temurin@25

The brew update command refreshes Homebrew's package list so you get the latest version. The --cask flag tells Homebrew to install the macOS package rather than using a Homebrew build formula. This installs Java to /Library/Java/JavaVirtualMachines/temurin-25.jdk/, the standard location macOS expects. No additional configuration is needed.

If you don't want Eclipse Temurin, use brew install --cask corretto@25 for Amazon Corretto or brew install --cask zulu@25 for Azul Zulu.

Why not brew install openjdk@25?

You might see recommendations to use brew install openjdk@25 (without --cask). This formula works, but it's "keg-only." That means Homebrew installs it without linking to standard locations. Most developer tools won't detect it until you manually create a symlink. Read Brew Install Java - Formula Method if you'd prefer to install Java 25 with a Homebrew formula. Some develpers will prefer this approach if they are accustomed to installing and configuring other programming languages with Homebrew.

Install Java 25 manually

If you prefer not to use Homebrew to install Java 25 from Eclipse Temurin, you can download the Java installer directly from adoptium.net/temurin/releases. Select macOS and choose aarch64 for Apple Silicon or x64 for Intel Macs. Download the .pkg installer, double-click it, and follow the prompts. The installer places Java at /Library/Java/JavaVirtualMachines/temurin-25.jdk/. Apple's macOS automatically detects JDKs in this location. Read Download Java for Mac for all download options and follow the instructions to Install Java on Mac.

Verify the installation

After installing, confirm Java 25 is working correctly. Run java -version to check. You should see output showing "25" in the version number. Also verify the compiler with javac -version to confirm you have the full JDK.

$ java -version
openjdk version "25.0.1" 2025-10-21
OpenJDK Runtime Environment Temurin-25.0.1+8 (build 25.0.1+8)
OpenJDK 64-Bit Server VM Temurin-25.0.1+8 (build 25.0.1+8, mixed mode)
$ javac -version
javac 25.0.1

Running a test program

For extra confidence, compile and run a test program using Java 25's new simplified syntax:

$ echo 'void main() { IO.println("Java 25 works!"); }' > Hello.java
$ java Hello.java

If you see "Java 25 works!" printed, everything is configured correctly. This demonstrates Java 25's compact source files feature. No class declaration or public static void main is required.

You can also test with traditional syntax if you prefer:

$ echo 'public class Test { public static void main(String[] args) { System.out.println("Hello!"); } }' > Test.java
$ javac Test.java
$ java Test

Read Check Java Version on Mac for detailed version verification steps.

Set JAVA_HOME

Java tools, such as Maven, Gradle, IntelliJ, and others, use the JAVA_HOME environment variable to find your JDK. Apple's macOS provides a helper utility to locate installed JDKs.

Run /usr/libexec/java_home -v 25 to find your Java 25 path. After finding the Java location, add these lines to your ~/.zprofile file to set JAVA_HOME and update PATH on every new shell:

export JAVA_HOME=$(/usr/libexec/java_home -v 25)
export PATH=$JAVA_HOME/bin:$PATH

See the articles Mac Shell Configuration and Set Mac Path for complete instructions.

After saving, run source ~/.zprofile to apply the changes (or close and reopen your terminal). Verify with echo $JAVA_HOME.

Read Set JAVA_HOME on Mac for complete JAVA_HOME configuration instructions.

JAVA_HOME sets the default version

If you have multiple Java versions installed, the JAVA_HOME configuration will set the version to use. List all installed versions with /usr/libexec/java_home -V to see what's on your system. If you are maintaining projects on different Java versions and need to switch versions frequently, consider a version manager like SDKMAN or jEnv. Read Java Version Managers for tools that automate switching.

Troubleshooting

If you see "java: command not found" after installation, verify Java is installed by checking /Library/Java/JavaVirtualMachines/. If the folder exists but Java isn't found, add JAVA_HOME to your shell configuration. If you see the wrong version, list all versions with /usr/libexec/java_home -V and explicitly set Java 25. Read Fix "java: command not found" for detailed troubleshooting steps.

Quick reference

Here are the essential commands for reference:

# Install Java 25 with Homebrew (recommended)
$ brew update
$ brew install --cask temurin@25
# Check version
$ java -version
$ javac -version
# List all installed JDKs
$ /usr/libexec/java_home -V
# Find Java 25 path
$ /usr/libexec/java_home -v 25
# Set JAVA_HOME (add to ~/.zprofile)
export JAVA_HOME=$(/usr/libexec/java_home -v 25)
export PATH=$JAVA_HOME/bin:$PATH
# Reload shell config
$ source ~/.zprofile
# Test Java 25 simplified syntax
$ echo 'void main() { IO.println("Hello!"); }' > Hello.java
$ java Hello.java

Frequently asked questions

Should I use Java 25 or Java 21? Choose Java 25 for new projects. Both are LTS releases, but Java 25 has longer support (until 2033 versus 2031 for Java 21) and includes compact source files, flexible constructors, scoped values, and better performance. Java 21 free updates continue until September 2026, giving you a year to migrate.

Is Java 25 stable for production? Yes. As an LTS release, Java 25 underwent extensive testing before release. Oracle, Amazon, Azul, and the Eclipse Foundation all provide production-ready builds. Major frameworks like Spring Boot actively support it.

When should I upgrade to Java 25? Upgrade when your dependencies support it—most modern frameworks already do. For greenfield projects, start with Java 25. For existing projects, test thoroughly in a staging environment first. The one-year overlap with Java 21 free updates gives you time to plan.

Does Java 25 support Apple Silicon natively? Yes. All major distributions provide native ARM64 builds for M-series Macs. These run significantly faster than Intel builds under Rosetta 2 emulation. See Java on Apple Silicon or Intel Macs.

What's new with the void main() syntax? Java 25 finalizes compact source files. You can now write void main() { } instead of public static void main(String[] args) { }. The class declaration is optional, and module java.base is automatically imported. This makes Java friendlier for scripting and learning.

What's Next

With Java 25 installed, you're ready to build. Start a new project with your favorite framework, update Maven or Gradle settings to target Java 25, or explore compact source files with a sample application. If you work on multiple projects with different Java versions, see Java Version Managers or Install SDKMAN for Java on Mac for tools that automate switching. If you ever need to remove Java, see Uninstall Java on Mac.

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.