New Features in Java 9

More than three years after the release of Java 8, the next version is now just around the corner with a tentative release date of September 21st, 2017. You may have heard about Java 9’s module system, but there's even more to this new version. Here are nine exciting new features that will ship with Java 9 The Java Platform module system Modular JAR files contain an additional module descriptor. In this module descriptor, dependencies on other modules are expressed through`requires` statements. Additionally, `exports` statements control which packages are accessible to other modules. All non-exported packages are encapsulated in the module by default. Here's an example of a module descriptor, which lives in `module-info.java`: Let’s start with the big one – bringing modularity into the Java platform. A modular system provides capabilities similar to OSGi framework’s system. Modules have a concept of dependencies, can export a public API and keep implementation details hidden/private. One of the main motivations here is to provide modular JVM, which can run on devices with a lot less available memory. The JVM could run with only those modules and APIs which are required by the application. Check out this link for a description of what these modules are. Also, JVM internal (implementation) APIs like com.sun.* are no longer accessible from application code. Simply put, the modules are going to be described in a file called module-info.java located in the top of java code hierarchy:


module com.baeldung.java9.modules.car {
requires com.baeldung.java9.modules.engines;
exports com.baeldung.java9.modules.car.handling;
}