Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Configure Eclipse for Java 9

This wiki page explains how you can configure Eclipse to launch with Java 9 and above. This also explains how the Java 9 support can be installed for Eclipse 4.7. Java 9 reorganizes the runtime into modules, but this conflicts with the way Eclipse organizes its own runtime.


Note.png
Users who install Eclipse Oxygen 4.7.1a are able to launch with Java 9 and get Java 9 support, and the configuration described below won't be necessary anymore. There might be cases which won't work, see item 3 below in that case.


Download Java 9

You need to download and install a Java 9 VM, e.g. from http://jdk.java.net/9. If you are developing Java applications, or are on macOS, you should definitely get the JDK.

Configure Eclipse to run on Java 9 VM

If Java is automatically found when launching Eclipse, you need to specify the location of your Java VM. If you already do this, simply replace it with a Java 9 VM. Otherwise it can easily be done by adding something like:

-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe

following the --launcher.appendVmargs line to the eclipse.ini.

Configure Eclipse for Java 9 modules

Since the Eclipse SDK uses types that aren't in the java.base module, you need to add the following vmargs to eclipse.ini:

--add-modules=ALL-SYSTEM

Your project might fail to run because you use types that are neither in java.base or java.se.ee, e.g. types from javafx.base. In that case you have to figure out which module(s) you need to add with --add-modules.

  • Only works in JDK 8, but not in JDK 9: Run jdeps fully.qualified.classname
  • In Eclipse with Java 9 Support for Oxygen (see below), you can open the type in a JavaSE-9 JRE and perform Show In > Package Explorer. Inside the "JRE System Library" node, the Package Explorer will show the module in which that type resides.

eclipse.ini summary

Your eclipse.ini should contain something like:

--launcher.appendVmargs
-vm
C:\Program Files\Java\jdk-9\bin\javaw.exe
-vmargs
-Dosgi.requiredJavaVersion=1.8
--add-modules=ALL-SYSTEM

Each argument must be on its own line, and every line after -vmargs is passed as an argument to the JVM. Incorrect arguments after the -vmargs line often cause the JVM to exit immediately.

Install Eclipse Java 9 Support for Oxygen releases before Oxygen.1a

This is useful if you have to debug problems, e.g. when it fails to run your project.

This is essential if you want to run JUnit tests in the Eclipse IDE using Java 9.

We recommend to install the support via Eclipse Marketplace because it is crucial that the Eclipse install, the Java 9 VM and the patch match. If you are not using an EPP with a pre-installed Marketplace Client, you must install it first (from the General Purpose Tools category of the http://download.eclipse.org/releases/oxygen P2 repo).

Another way to install it is to use Ed's Oomph based installer described here: https://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg14178.html.

Specify a Java 9 JRE

Use Window->Preferences->Java->Install JREs to make your Java 9 VM available within Eclipse.

You may want to associate Java 9 with some Execution Environments to force a rebuild using Java 9.

Back to the top