What Are the New Features in Java 9

On September 21, 2017, we witnessed the release of Java 9. It was a long time coming, considering that its features have been discussed for over 5 years and the release was put off several times (originally the release was to take place in March 2017)

On September 21, 2017, we witnessed the release of Java 9. It was a long time coming, considering that its features have been discussed for over 5 years and the release was put off several times (originally the release was to take place in March 2017). But the waiting was totally worth it. What we need to do now is to learn to enjoy the new features in Java 9, especially in the eye of discontinued support of Java 7 and the announced end of support for Java 8, which is scheduled for September 2018. So let’s check out what is new to play with in Java 9.

What Are the Great New Features in Java 9?

The new edition of Java brought a variety of useful improvements. We won’t tire you by listing all of them and drilling each down. Instead, we suggest you check out this list of the enhancements that we think of as the most important ones.

Module System
This is unarguably the most significant change brought upon by Java’s new version. This novelty addresses the issue of the difficulties we faced because of the necessity of using JAR files for developing Java-based applications. The introduction of the Module System is a part of the Jigsaw project, which aims to facilitate the developer’s job by breaking the code down to independent modules. This is a great development, especially for large-scale, enterprise-grade projects which might need scaling up in the future.
The newly introduced system features:

Let’s linger over the last point for a bit, as this one deserves our special attention. Now that you have multiple interdependent modules making up your app, some purely yours, others taken from the JDK, with specified dependencies between them, why not use the data about these dependencies to assemble only those modules that are necessary to have the app running? Java Linker does exactly this thing. It allows linking and optimizing a set of modules and their dependencies to create a minimal run-time image. Great, yeah?

JShell
REPL (Read-Eval-Print Loop) is an interactive programming environment for writing programs that are to be executed piece by piece, outputting the result in the console, thus providing instant feedback. You might have been asking yourself how a programming language like Java hasn’t had its own shell up until recently. Well, we’ve been asking ourselves this question for years, too! Now that we have JShell, Java development became a more enjoyable experience.

HTTP/2 Client
The HTTPClient introduced in the latest Java edition supports HTTP/2 and WebSocket protocols, substituting HttpURLConnection with a more highly-performing option. The new API is packed in java.net.http, which supports both synchronous and asynchronous modes. With the new API, developers can create HTTP connections that are quick to set up and easy to maintain, and besides don’t require any third-party libraries. All this allows building more responsive apps, which is obviously a great plus.

Stream API developments
Stream API got a number of handy capabilities. For example, dropWhile and takeWhile methods. The first one drops the first element failing the predicate and all the following ones, whether they match the condition or not, and forms a new string with them. The takeWhile method does exactly the opposite – it returns all elements until the predicate fails. As you can imagine, both methods work differently on ordered and unordered streams.
Another enhancement is the iterate() method, which allows substituting loops with streams. To execute it, you need to input the initialValue of the new stream, the predicate condition, and then indicate what is the next element to be generated.

Private interface methods
Another new feature in Java 9 brought us the opportunity to write private and private static interface methods using the private and private static access modifier. This development allows skipping the need to write duplicate code, thus making the code more reusable. Apart from that we now can expose just the methods implementations we need to be exposed.
Java 9 presents a magnitude of new features, and the ones described above are just the tip of the iceberg. Surely, the introduction of the new version is a change for the better, both for development teams and the end user. Thinking of a Java-based project for your business? We at Softvelopers are ready to help you with it! Boasting 17 years of Java development services behind our backs, our team can take your idea and bring it to life in the most efficient way. Softvelopers takes up projects of developing enterprise software, desktop apps, mobile applications and web-based software.

Leave a Reply

Your email address will not be published. Required fields are marked *