Java9 new features-power node

Java 9 was released on September 22, 2017, bringing many new features, the most important of which is the modular system that has been implemented. Next, we will introduce the new features of Java 9 in detail.

What's new in Java 9

• Module system: A module is a container for packages. One of the biggest changes in Java 9 is the introduction of a module system (Jigsaw project).

• REPL (JShell): Interactive programming environment.

• HTTP 2 client: The HTTP/2 standard is the latest version of the HTTP protocol. The new HTTPClient API supports WebSocket and HTTP2 streaming and server push features.

• Improved Javadoc: Javadoc now supports searching in API documentation. In addition, the output of Javadoc is now compatible with HTML5 standards.

• Multi-version compatible JAR package: The multi-version compatible JAR function allows you to create a class version that you can choose to use when you run library programs in a specific version of the Java environment.

• Collection factory methods: In the List, Set and Map interfaces, new static factory methods can create immutable instances of these collections.

• Private interface method: Use private methods in the interface. We can use the private access modifier to write private methods in the interface.

• Process API: Improved API to control and manage operating system processes. Introduce java.lang.ProcessHandle and its nested interface Info to allow developers to escape the dilemma of having to use native code to obtain the PID of a native process.

• Improved Stream API: The improved Stream API adds some convenient methods to make stream processing easier, and uses collectors to write complex queries.

• Improve try-with-resources: If you already have a resource that is final or equivalent to a final variable, you can use the variable in the try-with-resources statement without declaring a new one in the try-with-resources statement variable.

• Improved deprecated annotation @Deprecated: The annotation @Deprecated can mark the state of the Java API, which can indicate that the marked API will be removed or destroyed.

• Improved Diamond Operator: Anonymous classes can use Diamond Operator.

• Improve the Optional class: java.util.Optional adds a lot of new useful methods, Optional can be directly converted to stream.

• Multi-resolution image API: Define multi-resolution image API, developers can easily operate and display images of different resolutions.

• Improved CompletableFuture API: The asynchronous mechanism of the CompletableFuture class can perform operations when the ProcessHandle.onExit method exits.

• Lightweight JSON API: Built-in a lightweight JSON API

• Reactive Streams API: Java 9 introduced a new Reactive Streams API to support reactive programming in Java 9.

More new features can be found on the official website: https://docs.oracle.com/javase/9/whatsnew/toc.htm#JSNEW-GUID-C23AFD78-C777-460B-8ACE-58BE5EA681F6

JDK 9 download link: http://www.oracle.com/technetwork/java/javase/downloads/jdk9-doc-downloads-3850606.html

In the example of the article about Java 9, we all use the jdk 1.9 environment, you can use the following command to view the current jdk version:

$ java -version
java version “9-ea”
Java™ SE Runtime Environment (build 9-ea+163)
Java HotSpot™ 64-Bit Server VM (build 9-ea+163, mixed mode)

Guess you like

Origin blog.csdn.net/weixin_49543720/article/details/110957356