Released on September 21, 2017, Java 9 brought some of the biggest changes to the Java platform since Java 5. It wasn’t just a minor update — it laid the groundwork for the modern Java ecosystem.
Let’s dive into the most important features and improvements introduced in Java 9.
🔥 1. Java Platform Module System (JPMS) – Project Jigsaw
Modularity was the biggest highlight of Java 9. With JPMS, Java became modular for the first time.
✅ What it means:
-
Split the JDK into interoperable modules.
-
Applications can also be modularized using
module-info.java. -
Improved security, maintainability, and performance.
Example:
📌 This change paved the way for more scalable applications and lightweight deployments.
🧪 2. JShell (REPL) – Read-Eval-Print Loop
Java finally got an interactive command-line tool like Python or Ruby.
Benefits:
-
Great for learning and testing code snippets.
-
No need to write full classes or methods just to test logic.
Example:
🚀 Super useful for experimentation and quick debugging.
📦 3. Improved JDK Modularization
The JDK itself was modularized into about 95 modules (like java.base, java.sql, java.xml, etc.).
Why it matters:
-
Developers can create custom runtimes using
jlinkby including only the modules they need. -
Smaller application size.
-
Reduced attack surface.
📁 4. JLink – Java Linker Tool
Create your own minimized JRE using only the modules your app requires.
Example:
🎯 Great for embedded systems and microservices.
🧵 5. Improved Process API
The ProcessHandle and ProcessHandle.Info classes added to make managing OS processes easier and more powerful.
Example:
🔍 Useful for monitoring and managing system processes directly from Java.
🧰 6. Stream API Enhancements
Java 9 added some long-awaited methods to the Stream API.
New methods:
-
takeWhile() -
dropWhile() -
ofNullable() -
iterate()overload
Example:
📚 7. Optional Enhancements
-
Optional.ifPresentOrElse() -
Optional.or()
Example:
🧪 8. Private Interface Methods
Now you can define private methods inside interfaces to share logic among default or static methods.
Example:
🎯 Keeps interface code clean and DRY.
⚡ 9. Collection Factory Methods
Creating immutable lists, sets, and maps got much simpler.
Example:
🧊 These collections are immutable and throw exceptions if modified.
📉 10. Deprecated Features and Removed Tools
Java 9 started cleaning house:
-
Applet API deprecated.
-
Java EE modules (like
javax.xml.bind) marked as deprecated. -
Tools like
javahremoved.
⚠️ These deprecations were a sign of Java’s evolving ecosystem, pushing toward modern and modular alternatives.
🧠 Conclusion
Java 9 was a massive leap forward. It:
-
Introduced true modularity with Project Jigsaw.
-
Brought JShell to simplify coding and learning.
-
Enhanced core APIs (Streams, Optionals, Collections).
-
Enabled custom JREs for lean deployments.
💡 While Java 9 wasn’t a long-term support (LTS) version, it laid the foundation for the more widely adopted Java 11 and beyond.