Java9 New Features
# Java 9 New Features
Java 9 was released on September 22, 2017, bringing many new features, the most significant of which is the implemented module system. Next, we will introduce the new features of Java 9 in detail.
## Java 9 New Features
* **Module System**: A module is a container for packages. One of the biggest changes in Java 9 is the introduction of the module system (Project Jigsaw).
* **REPL (JShell)**: Interactive programming environment.
* **HTTP 2 Client**: HTTP/2 is the latest version of the HTTP protocol. The new HttpClient API supports WebSocket and HTTP/2 streams, as well as server push features.
* **Improved Javadoc**: Javadoc now supports searching within API documentation. Additionally, Javadoc output now conforms to HTML5 standards.
* **Multi-Release JAR Files**: The multi-release JAR feature allows you to create libraries that use different class versions depending on the specific Java version they are run on.
* **Collection Factory Methods**: New static factory methods in the List, Set, and Map interfaces allow you to create immutable instances of these collections.
* **Private Interface Methods**: You can use private methods in interfaces. We can write private methods in interfaces using the private access modifier.
* **Process API**: Improved API for controlling and managing operating system processes. Introduces `java.lang.ProcessHandle` and its nested interface `Info` to help developers avoid the common need to use native code to get a local process's PID.
* **Improved Stream API**: The improved Stream API adds some convenience methods, making stream processing easier and allowing you to write complex queries using collectors.
* **Improved try-with-resources**: If you already have a resource that is final or effectively final, you can use that variable in a try-with-resources statement without having to declare a new variable in the statement.
* **Improved @Deprecated Annotation**: The `@Deprecated` annotation can mark the status of a Java API, indicating that the marked API will be removed or is already broken.
* **Improved Diamond Operator**: Anonymous classes can now use the Diamond Operator.
* **Improved Optional Class**: `java.util.Optional` has added many new useful methods, and Optional can now be directly converted to a Stream.
* **Multi-Resolution Image API**: Defines a multi-resolution image API, making it easy for developers to manipulate and display images of different resolutions.
* **Improved CompletableFuture API**: The asynchronous mechanism of the `CompletableFuture` class can execute operations when the `ProcessHandle.onExit` method exits.
* **Lightweight JSON API**: A lightweight JSON API is built-in.
* **Reactive Streams API**: Java 9 introduces a new Reactive Streams API to support reactive programming in Java 9.
For more new features, please refer to the official website: [What's New in JDK 9](https://docs.oracle.com/javase/9/whatsnew/toc.htm)
JDK 9 Download: [http://www.oracle.com/technetwork/java/javase/downloads/jdk9-doc-downloads-3850606.html](http://www.oracle.com/technetwork/java/javase/downloads/jdk9-doc-downloads-3850606.html)
In the examples for the Java 9 article, we will use the jdk 1.9 environment. You can use the following command to check the current jdk version:
$ java -version java version "9-ea"Java(TM) SE Runtime Environment (build 9-ea+163)Java HotSpot(TM) 64-Bit Server VM (build 9-ea+163, mixed mode) Next, we will introduce the new features of Java 9 in detail:
| No. | Feature |
| --- | --- |
| 1 | (#) |
| 2 | [REPL (JShell)](#) |
| 3 | (#) |
| 4 | (#) |
| 5 | (#) |
| 6 | (#) |
| 7 | (#) |
| 8 | (#) |
| 9 | (#) |
| 10 | [@Deprecated](#) |
| 11 | (#) |
| 12 | (#) |
| 13 | (#) |
| 14 | (#) |
YouTip