The Java 9 general availability release is just under a month away, but the builds available right now are already feature complete. If you can’t wait to try some Java 9 capabilities, you can start developing with Java 9 in Eclipse right now!
Installing the Java 9 Support
- You need an Oxygen-based install of Eclipse – ensure you’re using the R version and not milestone or integration builds.
- Open the Java 9 Support marketplace entry in a browser: https://marketplace.eclipse.org/content/java-9-support-beta-oxygen
- Drag and drop the Install button from the webpage into your Eclipse IDE to start the installation.
Note: In the unlikely event that the above steps don’t work, you probably do not have the Eclipse Marketplace Client installed – you can then choose Help > Install New Software… and use the following update site in the wizard to install the Java 9 patch: http://download.eclipse.org/eclipse/updates/4.7-P-builds
Using Java 9
It goes without saying that you must have a recent Java 9 JRE or JDK installed. If you don’t, get it here: http://jdk.java.net/9/
The first thing to do is to set up your workspace to use a Java 9 JRE.
Now when you create a project, use the JavaSE-9 execution environment, or select the specific JRE you created in your previous step.
Once your project is created, you have the freedom to do everything from creating and using modules to exploring the new Collections API or using one of my favorite features, the new additions to the Process API.
And by the way, if you are wondering why my Eclipse dark theme looks so cool, it’s the Darkest Dark theme.
Note that you don’t need to run Eclipse itself with Java 9 to be able to use Java 9 for development, or even to execute Java 9 applications and JUnit tests. However, if you do want to do this, please read this article. For more examples of Eclipse’s Java 9 support, see this page.
Java 9 Highlights
A module is a named, self-describing collection of code and data – the JDK itself has been divided into a set of modules. What does this mean? Improved performance by using only the parts of the JDK, or a modularized third-party library that you need. Better maintainability of your own complex code; with modules you have better encapsulation, can cleanly expose APIs, and have explicitly declared dependencies.
Private Interface Methods
An extension of the default methods introduced in Java 8, the private interface methods make it easy to share code within interfaces while keeping it unexposed.
Factory Methods for Collections
Want to create an immutable collection easily? You no longer need several add statements. Try this:
List<String> myList = List.of(“one”, “two”, “three”);
Process API Improvements
Sick of using third-party libraries, or even executing shell scripts to do something as simple as getting the PID of a process? I know I am. With Java 9, that’s now a thing of the past with the ProcessHandle#pid method. There are several other improvements here that allow better Java <> OS interaction too.
There are several other key features, like HTTP /2 support, multi-release JARs, a better Stream API, improved Javadocs, and Applets (remember them?) are finally getting deprecated. These are just my highlights. For an exhaustive list, have a look at Oracle’s what’s new document.