Part 2 of 12

Setting Up Java 25: Install, Tooling & IDE Configuration

Installing Java 25

SDKMAN! is the easiest way to install and switch between Java versions on macOS and Linux.

# Install SDKMAN! if you don't have it
curl -s "https://get.sdkman.io" | bash
source "$HOME/.sdkman/bin/sdkman-init.sh"

# List available Java 25 distributions
sdk list java | grep "25"

# Install Eclipse Temurin 25 (open-source, most common)
sdk install java 25-tem

# Set as default globally
sdk default java 25-tem

# Verify
java -version
# openjdk version "25" 2025-09-16

Switch between versions per project:

# Use Java 25 only in the current shell
sdk use java 25-tem

# Pin a project to Java 25 (creates .sdkmanrc)
sdk env init

Option 2: Homebrew (macOS)

brew install --cask temurin@25

# Verify
/usr/libexec/java_home -V
export JAVA_HOME=$(/usr/libexec/java_home -v 25)
java -version

Option 3: Direct Download

Download from Adoptium or Oracle and set JAVA_HOME manually:

# macOS / Linux
export JAVA_HOME=/path/to/jdk-25
export PATH=$JAVA_HOME/bin:$PATH

# Windows (PowerShell)
$env:JAVA_HOME = "C:\Program Files\Java\jdk-25"
$env:PATH = "$env:JAVA_HOME\bin;$env:PATH"

Gradle Configuration

build.gradle (Groovy DSL)

plugins {
    id 'java'
}

java {
    toolchains {
        languageVersion = JavaLanguageVersion.of(25)
    }
}

tasks.withType(JavaCompile).configureEach {
    options.release = 25
}

build.gradle.kts (Kotlin DSL)

plugins {
    java
}

java {
    toolchains {
        languageVersion = JavaLanguageVersion.of(25)
    }
}

tasks.withType<JavaCompile>().configureEach {
    options.release = 25
}

Enabling Preview Features in Gradle

Some Java 25 features (Primitive Patterns, Structured Concurrency, Stable Values) are still in preview. You must opt in explicitly:

tasks.withType<JavaCompile>().configureEach {
    options.release = 25
    options.compilerArgs.add("--enable-preview")
}

tasks.withType<JavaExec>().configureEach {
    jvmArgs("--enable-preview")
}

tasks.withType<Test>().configureEach {
    jvmArgs("--enable-preview")
}

Maven Configuration

pom.xml

<properties>
    <maven.compiler.release>25</maven.compiler.release>
    <maven.compiler.source>25</maven.compiler.source>
    <maven.compiler.target>25</maven.compiler.target>
</properties>

<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.13.0</version>
            <configuration>
                <release>25</release>
            </configuration>
        </plugin>
    </plugins>
</build>

Enabling Preview Features in Maven

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.13.0</version>
    <configuration>
        <release>25</release>
        <compilerArgs>
            <arg>--enable-preview</arg>
        </compilerArgs>
    </configuration>
</plugin>

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.2.5</version>
    <configuration>
        <argLine>--enable-preview</argLine>
    </configuration>
</plugin>

IntelliJ IDEA Configuration

IntelliJ IDEA 2025.2+ has full Java 25 support including syntax highlighting for preview features.

  1. File → Project Structure → Project

    • Set SDK to Java 25
    • Set Language Level to 25 (or 25 (Preview) for preview features)
  2. File → Settings → Build, Execution, Deployment → Compiler → Java Compiler

    • Add --enable-preview to “Additional command line parameters”
  3. IntelliJ will automatically detect build.gradle / pom.xml settings if you import the project correctly.


VS Code Configuration

Install the Extension Pack for Java (includes Language Support for Java by Red Hat).

.vscode/settings.json:

{
    "java.configuration.runtimes": [
        {
            "name": "JavaSE-25",
            "path": "/path/to/jdk-25",
            "default": true
        }
    ],
    "java.compile.nullAnalysis.mode": "automatic"
}

Verify Your Setup

Create Hello.java — this is a Compact Source File (JEP 512, final in Java 25). No class declaration needed:

void main() {
    System.out.println("Java " + Runtime.version().feature() + " is running!");
}

Run it directly:

java Hello.java
# Java 25 is running!

If you see Java 25 is running! — your setup is complete.


Next up: Flexible Constructor Bodies →