Working With Java 9 in Eclipse

DZone 's Guide to

Working With Java 9 in Eclipse

With Java 9 fast approaching, we take a look at how to get your instance of Eclipse ready to handle working with the upcoming version of Java.

· Java Zone ·
Free Resource

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

  1. You need an Oxygen-based install of Eclipse – ensure you’re using the R version and not milestone or integration builds.
  2. Open the Java 9 Support marketplace entry in a browser: https://marketplace.eclipse.org/content/java-9-support-beta-oxygen
  3. Drag and drop the Install button from the webpage into your Eclipse IDE to start the installation.  java9blog1

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

Module System

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: 

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.

eclipse ,java ,java 9 ,jpms ,tutorial

Published at DZone with permission of Brian Fernandes , DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}