Overview of New Features in Java 25
Introduction
Java 25 was released on 16th September 2025. It is a long-term support (LTS) release, the successor to Java 21Click to read: Java 21. Its eighteen JDK Enhancement Proposals (JEPs) made Java simpler to start with - small programs no longer need a class declaration - and finalized several features which had been in preview since Java 21 or 22: module imports, flexible constructor bodies and scoped values. It also made applications start faster and use less memory, and added a Key Derivation Function API. This article gives an overview of the new features in Java 25, and then summarizes all the major changes since Java 21, with links to detailed tutorials.
Language and libraries
Previews and incubators
Upgrading from Java 21 to 25
- Compact Source Files and Instance Main Methods - JEP 512 - a program can be just
void main() { IO.println("Hello"); }, and the newIOclass handles console input and output. Read about compact source files and instance main methodsClick to read tutorial: Java 25 Compact Source Files and Instance main Methods. - Module Import Declarations - JEP 511 -
import module java.base;imports every package a module exports. Read about module import declarationsClick to read tutorial: Java 25 Module Import Declarations with Examples. - Flexible Constructor Bodies - JEP 513 - statements before
super(...)andthis(...). Read about flexible constructor bodiesClick to read tutorial: Java 25 Flexible Constructor Bodies with Examples. - Scoped Values - JEP 506 - immutable, bounded sharing of data with called code and child threads, an alternative to
ThreadLocal. Read the scoped values tutorialClick to read tutorial: Java 25 Scoped Values Tutorial with Examples. - Key Derivation Function API - JEP 510 -
javax.crypto.KDF, with HKDF. Read about the Key Derivation Function APIClick to read tutorial: Java 25 Key Derivation Function (KDF) API Tutorial.
- Compact Object Headers - JEP 519 - object headers shrink from 12 to 8 bytes with
-XX:+UseCompactObjectHeaders. Read about compact object headersClick to read tutorial: Java 25 Compact Object Headers Explained. - Ahead-of-Time Command-Line Ergonomics - JEP 514 and Ahead-of-Time Method Profiling - JEP 515 - an AOT cache is created in one step with
-XX:AOTCacheOutput, and stores method profiles so the JIT compiler warms up faster. Read about the AOT cacheClick to read tutorial: AOT Cache in Java 24 and 25: Faster Startup. - Generational Shenandoah - JEP 521 - Shenandoah's generational mode, experimental in Java 24, became a product feature.
- JFR improvements - JEPs 509, 518 and 520 - experimental CPU-time profiling on Linux, cooperative sampling for more accurate and safer stack sampling, and method timing and tracing, which records how often and how long chosen methods run without changing the code. See the JFR event streaming tutorialClick to read: JFR event streaming tutorial for how to consume JFR events.
- Remove the 32-bit x86 Port - JEP 503 - the JDK no longer supports 32-bit x86 processors.
- Stable Values (Preview) - JEP 502 - values which are initialized at most once, lazily, yet treated by the JVM as constants for optimization; renamed lazy constants in Java 26.
- PEM Encodings of Cryptographic Objects (Preview) - JEP 470 - reading and writing keys and certificates in the PEM text format.
- Primitive Types in Patterns, instanceof, and switch (Third Preview) - JEP 507, Structured Concurrency (Fifth Preview) - JEP 505 and Vector API (Tenth Incubator) - JEP 508 - still evolving.
Each release also has its own overview: Java 22Click to read tutorial: Overview of New Features in Java 22, Java 23Click to read tutorial: Overview of New Features in Java 23 and Java 24Click to read tutorial: Overview of New Features in Java 24.
- Security Manager: code which calls
System.setSecurityManager()fails on Java 24 and later; remove it. - Native access and Unsafe: applications using JNI or the FFM API should add
--enable-native-accessto avoid warnings, and libraries usingsun.misc.Unsafememory access should be upgraded. - Virtual threads: if you avoided
synchronizedbecause of pinning on Java 21, that is no longer necessary. - Quick wins: try
-XX:+UseCompactObjectHeadersfor lower memory use, and an AOT cache for faster startup - both need only command-line changes.
Continue Reading Java 22 to 25 Tutorials
Java 25 Compact Source Files and Instance main MethodsClick to read tutorial: Java 25 Compact Source Files and Instance main Methods Java 25 Module Import Declarations with ExamplesClick to read tutorial: Java 25 Module Import Declarations with Examples Java 25 Flexible Constructor Bodies with ExamplesClick to read tutorial: Java 25 Flexible Constructor Bodies with Examples Java 25 Scoped Values Tutorial with ExamplesClick to read tutorial: Java 25 Scoped Values Tutorial with Examples Java 25 Compact Object Headers ExplainedClick to read tutorial: Java 25 Compact Object Headers Explained Java 25 Key Derivation Function (KDF) API TutorialClick to read tutorial: Java 25 Key Derivation Function (KDF) API Tutorial Java 24 Quantum-Resistant Crypto: ML-KEM and ML-DSAClick to read tutorial: Java 24 Quantum-Resistant Crypto: ML-KEM and ML-DSA Overview of New Features in Java 22Click to read tutorial: Overview of New Features in Java 22 Overview of New Features in Java 23Click to read tutorial: Overview of New Features in Java 23
Java 25 Compact Source Files and Instance main MethodsClick to read tutorial: Java 25 Compact Source Files and Instance main Methods Java 25 Module Import Declarations with ExamplesClick to read tutorial: Java 25 Module Import Declarations with Examples Java 25 Flexible Constructor Bodies with ExamplesClick to read tutorial: Java 25 Flexible Constructor Bodies with Examples Java 25 Scoped Values Tutorial with ExamplesClick to read tutorial: Java 25 Scoped Values Tutorial with Examples Java 25 Compact Object Headers ExplainedClick to read tutorial: Java 25 Compact Object Headers Explained Java 25 Key Derivation Function (KDF) API TutorialClick to read tutorial: Java 25 Key Derivation Function (KDF) API Tutorial Java 24 Quantum-Resistant Crypto: ML-KEM and ML-DSAClick to read tutorial: Java 24 Quantum-Resistant Crypto: ML-KEM and ML-DSA Overview of New Features in Java 22Click to read tutorial: Overview of New Features in Java 22 Overview of New Features in Java 23Click to read tutorial: Overview of New Features in Java 23