Configure Eclipse for Java 9
This wiki page explains how you can configure Eclipse to launch with Java 9. This also explains how the Java 9 support can be installed for Eclipse 4.7
Download Java 9
You need to download and install a Java 9 VM, e.g. from http://jdk.java.net/9.
Configure Eclipse to run on Java 9 VM
Unless you have Java 9 on your system path, you need to specify the use 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:
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
- In Eclipse with Java 9 Support (BETA) 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.
If you encounter an exception such as IllegalAccessException or InaccessibleObjectException, add the following after -vmargs in eclipse.ini:
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 --permit-illegal-access
Note: Java 9 is still in early access, and hence the options are yet to be stable. It is possible that the info given here will change over time. Currently verified with Java 9 EA 169.
Install Eclipse Java 9 Support (BETA)
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 https://marketplace.eclipse.org/content/java-9-support-beta-oxygen/ 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.