Java 9 introduced several major enhancements that changed how developers write and manage Java applications. Here are some of the standout features of Java 9:

1. Java Platform Module System (Project Jigsaw)

  • Helps improve scalability, security, and maintainability.
  • Allows developers to break down applications into smaller, manageable modules.
  • Avoids issues related to classpath dependencies.

2. JShell: Interactive Java REPL

  • First-ever Read-Eval-Print Loop (REPL) for Java.
  • Enables developers to run snippets of Java code without needing a full class.
  • Speeds up experimentation and debugging.

3. Improved Process API

  • Introduced methods for working with OS processes in a more convenient way.
  • Helps developers monitor and manage system processes efficiently.

4. HTTP 2 Client

  • Provides a new API for HTTP requests.
  • Supports HTTP/2 and WebSockets.
  • Improves efficiency and performance over the older HttpURLConnection.

5. Factory Methods for Collections

  • New static factory methods in List, Set, and Map interfaces.
  • Allows quick creation of immutable collections:
    List<String> names = List.of("Alice", "Bob", "Charlie");
    

6. Stream API Enhancements

  • Introduced new methods like takeWhile(), dropWhile(), and iterate() for improved stream processing.

7. Private Methods in Interfaces

  • Interfaces can now have private methods to help with code reuse.

Java 9 was a significant step forward in modularization and developer-friendly improvements.