New Features of JDK 9
JDK 9 adds a range of language and runtime enhancements—including a new module system, JShell REPL, upgraded Stream API, HTTP client, and internal changes to strings and exception handling—to improve modularity, performance, and developer productivity across Java applications.
JDK 9 New Features
JDK 9 introduces a series of language and runtime enhancements that improve modularity, performance, and developer productivity.
1. Directory Structure – The JDK directory layout has been reorganized; the article shows the pre‑JDK 9 layout and the new layout introduced after JDK 9.
After JDK 9 the directory structure changes as illustrated below.
2. JShell (REPL) Tool – JShell provides an interactive command‑line environment for evaluating Java snippets without a full IDE, useful for quick experiments and learning.
After launching JShell you can execute simple Java statements directly, as shown in the screenshots.
3. Modularity (Project Jigsaw) – Java 9 introduces a module system that allows a program to declare explicit dependencies, enabling the JVM to load only the required modules at runtime, reducing memory usage and start‑up time.
Modules are linked via module‑info.java and exported packages, as illustrated in the example screenshots.
4. Multi‑Release JARs – JDK 9 supports JAR files that contain version‑specific class files, allowing a single library to run on older Java versions (6, 7, 8) while taking advantage of newer APIs when executed on newer runtimes.
5. Interface Enhancements – Interfaces can now contain private methods, in addition to abstract, default, and static methods, enabling better code reuse within interfaces.
6. Diamond Operator Upgrade – The diamond operator now supports anonymous class creation with empty type arguments.
7. Try‑with‑Resources Improvements – The try‑with‑resources statement has been simplified; resources can be declared without an explicit variable, and final or effectively final resources are handled more cleanly.
Java 7/8 handling (middle image) and Java 9 handling (bottom image) are compared.
8. Identifier Restrictions – The underscore character '_' can no longer be used as an identifier name.
9. String Internal Representation – Java 9 replaces the internal char[] storage of String with a byte[] using a compact string representation (Latin‑1 or UTF‑16), reducing memory consumption.
StringBuilder and StringBuffer also adopt the new byte‑based storage.
10. Stream API Additions – Four new methods are added: takeWhile , dropWhile , ofNullable , and an overloaded iterate . The article demonstrates takeWhile ending a stream when a condition is met, while dropWhile does the opposite; ofNullable allows null elements without NPE, and iterate can produce infinite streams.
11. HttpClient API – Java 9 introduces a built‑in HttpClient API that replaces the need for external libraries such as Apache HttpClient for most HTTP communication tasks.
All of these features aim to improve performance, memory usage, and developer experience in Java applications.
Java Architect Essentials
Committed to sharing quality articles and tutorials to help Java programmers progress from junior to mid-level to senior architect. We curate high-quality learning resources, interview questions, videos, and projects from across the internet to help you systematically improve your Java architecture skills. Follow and reply '1024' to get Java programming resources. Learn together, grow together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.