Java 9 New Features Tutorial
1. Introduction
In this example, I would like to show you how to get started withJava 9 and write a simple Hello World program. Here, I present a simple example to get started along with details of some of the important new features.
Table Of Contents
Java 9 is a major release. At the time of writing of this article,JDK 9 is currently available for early access download on the oracle site and is expected to be released on July 27, 2017. This document attempts to summarize details on how to get started withJDK 9 and some of the main features with this new release.
Complete list of features can be viewed at the oraclesite.
2. Getting started
To download the currently available early accessJDKorJRE 9, visithttp://jdk.java.net/9/

As shown in the image above, at the site, accept the license agreement and proceed to the download section as shown below.
Please select the appropriate OS and option for 32/ 64 bits for the OS to download theJDK/ JRE. It is also recommended to download the documentation along with theJDK/ JRE installation.
3. Running a Hello World program on Java 9
The directory structure has changed inJDK 9. The below section lists the steps to get a simpleHello World program to run onJDK 9 via command line.
JDK 9 installation on my windows machine looks like the image above.
A sampleHello World program is listed below, do keep in mind that this is a legacy class and does not use the new module feature introduced injava 9.
HelloWorldJDK9.java
public class HelloWorldJDK9 {public static void main(String[] args) {System.out.println("Hello world");}}To compile this class on theJDK 9 installed, run the belowjavaccommand. To run the generated class, use the regularjavacommand or run the class usingeclipse.
You may use eclipse or an IDE of your choice (may need installation of Java 9 support plugins).
4. Changes in Java 9 and new features
4.1 Version in class files
Verify the class file created in step 3 by running javap as shown below. The output of javap has major version listed (as highlighted in yellow). The version number for Java 9 compiled classes is 53 as against version 52 for Java 8 compiled classes.
4.2 Module system/ Jigsaw
Module system is one of the most important changes inJava 9. This provides an entirely new dimension to writing and deploying java code.JDK 9 has reorganizedJDKandJREinto set of modules as well. With the new module system, application would consist of a number of modules.
Also, with the modularisation ofJDK, source code has been restructured to make it easy to maintain. Class and resource files previously stored inlib/rt.jar andlib/tools.jar and other internal jars would be stored in different formats in the lib directory.
More details can be found at the open jdk sites for JEP261,200 and220.
4.3 Deprecation of Applet API
With newer web browser technologies available, Oracle plans to deprecate the Applet API and it is recommended to rewrite applets as support may be removed in future release.
Alternatives for applets and embedded JavaFX applications include Java Web Start and self-contained applications. Details are available at thislink.
4.4 HTML 5 javadocs
Java 9 will have support for creating javadocs in HTML 5 along with the existing HTML 4 support. Refer details at thejirafor this change.
4.5 G1 as default Garbage Collector
Java 9 has madeG1the new default garbage collector.G1 is expected to provide overall performance improvement. Also, some GC combinations that were deprecated inJava 8 have been removed.
Refer JEP214 for more details.
Here is a detailed summary of the flags and flag combinations that will stop working:
[box type=”shadow” ]DefNew + CMS : -XX:-UseParNewGC -XX:+UseConcMarkSweepGC
ParNew + SerialOld : -XX:+UseParNewGC
ParNew + iCMS : -Xincgc
ParNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC
DefNew + iCMS : -XX:+CMSIncrementalMode -XX:+UseConcMarkSweepGC -XX:-UseParNewGC
CMS foreground : -XX:+UseCMSCompactAtFullCollection
CMS foreground : -XX:+CMSFullGCsBeforeCompaction
CMS foreground : -XX:+UseCMSCollectionPassing[/box]
5. Summary
This article is aimed at providing a starter toJava 9 and some important new features.JDK 9 has some exciting new features and promises to change how we currently write and deploy java code.
6. References
Oraclesite has excellent details of the new JDK 9 features.

Thank you!
We will contact you soon.







