2

In order to test if a project is ready for java 9, I tried the last couple hours to get eclipse compiling the complete project.
Here's what I did:

I'm using XUbuntu in a virtual machine by the way...

I installed the latest openjdk-9-* packages and removed all java 8 packages.

I downloaded the eclipse installer for eclipse oxygen and installed the default version of eclipse for Java SE.

I started eclipse and installed the Java 9 Support Package from the marketplace and tried importing the gradle project.

Everything went more or less fine until this point. (Had a couple problems with the packages and eclipse threw some error messages but all in all it worked.)

The project was successfully imported,but I get this error messages:

The project was not built since its build path is incomplete. Cannot 
find the class file for java.lang.Object. Fix the build path then try 
building this project

The type java.lang.Object cannot be resolved. It is indirectly 
referenced from required .class files

When it's trying to refresh the workspace, I get the following error Message:

Errors occurred during the build.
Errors running builder 'Java Builder' on project '<projectName>'.
java.lang.NullPointerException

The standard output is full of FileNotFoundExceptions like this one:

java.io.IOException: /usr/lib/jvm/jrt-fs.jar not exist
    at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:122)
    at jdk.internal.jrtfs.JrtFileSystemProvider.newFileSystem(java.base@9-internal/JrtFileSystemProvider.java:108)
    at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:342)
    at java.nio.file.FileSystems.newFileSystem(java.base@9-internal/FileSystems.java:291)
    at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.initialize(JRTUtil.java:204)
    at org.eclipse.jdt.internal.compiler.util.JrtFileSystem.<init>(JRTUtil.java:181)
    at org.eclipse.jdt.internal.compiler.util.JRTUtil.getJrtSystem(JRTUtil.java:118)
    at org.eclipse.jdt.internal.compiler.util.JRTUtil.walkModuleImage(JRTUtil.java:147)
    at org.eclipse.jdt.internal.core.JavaProject.loadModulesInJimage(JavaProject.java:727)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:647)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:805)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:769)
    at org.eclipse.jdt.internal.core.JavaProject.computePackageFragmentRoots(JavaProject.java:577)
    at org.eclipse.jdt.internal.core.ClasspathChange.generateDelta(ClasspathChange.java:401)
    at org.eclipse.jdt.internal.core.DeltaProcessor.resourceChanged(DeltaProcessor.java:2096)
    at org.eclipse.jdt.internal.core.DeltaProcessingState.resourceChanged(DeltaProcessingState.java:473)
    at org.eclipse.core.internal.events.NotificationManager$1.run(NotificationManager.java:299)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:289)
    at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:152)
    at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:374)
    at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1469)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2253)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2267)
    at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:5624)
    at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run(WorkbenchRunnableAdapter.java:105)
    at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter$1.run(WorkbenchRunnableAdapter.java:118)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:56)

Which isn't suprising, since the JDK (and the respective file) is located at usr/lib/jvm/java-9-openjdk-amd64. In order to fix this issue, I created a symlink pointing from /usr/lib/jvm/jrt-fs.jar to /usr/lib/jvm/java-9-openjdk-amd64/jrt-fs.jar, which got rid of those errors, but eclipse searched for /usr/lib/jvm/modules which isn't existing as well...

Ignore the following part:
I tried appending --add-modules=java.se.ee (as suggested by the java 9 support plugin) to the launch arguments and added it, after this did nothing to the end of the eclipse.ini file which caused eclipse to no longer launch.

My eclipse.ini File:

-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
../../../.p2/pool/plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.500.v20161213-1756
-product
org.eclipse.epp.package.java.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
/usr/lib/jvm/java-9-openjdk-amd64/bin/ #Changing this to /usr/<folders>/bin/java changed nothing
-install
/home/robin/eclipse/java-oxygen/eclipse
-vmargs
-Dosgi.requiredJavaVersion=1.8
-XX:+UseG1GC
-XX:+UseStringDeduplication
-Dosgi.requiredJavaVersion=1.8
-Xms256m
-Xmx1024m
-Declipse.p2.max.threads=10
-Doomph.update.url=http://download.eclipse.org/oomph/updates/milestone/latest
-Doomph.redirection.index.redirection=index:/->http://git.eclipse.org/c/oomph/org.eclipse.oomph.git/plain/setups/
#--add-modules=java.se.ee
#Appending this command line argument here causes eclipse to not start - "Could not create JVM"
#This argument can of course also be passed via the command line directly
#But this changes nothing
Jacques Snyman
  • 4,115
  • 1
  • 29
  • 49
RoiEX
  • 1,186
  • 1
  • 10
  • 37
  • *"I tried appending --add-modules=java.se.ee (as suggested by the java 9 support plugin) to the launch arguments and added it, after this did nothing to the end of the eclipse.ini file which caused eclipse to no longer launch."* - I can't parse that sentence. Can you post your eclipse.ini? – the8472 Apr 30 '17 at 13:58
  • I can... Hang on a couple minutes – RoiEX Apr 30 '17 at 14:06

4 Answers4

1

You can also try this to completely configure the Eclipse with Java 9 step by step official. Configure Eclipse for Java 9

Muhammad Siddique
  • 960
  • 1
  • 14
  • 31
0

Edit eclipse.ini and set the -vm argument to point to /usr/lib/jvm/java-9-openjdk-amd64/bin/java

the8472
  • 40,999
  • 5
  • 70
  • 122
  • Did that as well... Same result. This solution seems to only work on Windows – RoiEX Apr 30 '17 at 14:04
  • @RoiEX that's weird... I am on Mac with Eclipse Oxygen and jdk-9 and everything is fine. Could you check http://stackoverflow.com/questions/43165556/with-java-9-ea-eclipse-fails-to-install-and-show-error-an-error-has-occurred and see if you followed the exact steps? – Eugene May 02 '17 at 07:25
  • And don't forget "--add-modules=ALL-SYSTEM" in "-vmargs" section. – Stéphane Millien Aug 31 '18 at 20:35
0

I had the same issue. Eclipse can not find jrt-fs.jar in JDK root directory. Try running your project with Java 9 JRE instead. Complete step by step solution described here

filip_j
  • 993
  • 1
  • 14
  • 22
-1

I had the same problem with openjdk-9 in Linux Mint with Oxygen.
I noticed that the jdk version provided by the repo of my distro (version: 9-internal) is quite different in the launcher options it has.
For example the option --add-modules=ALL-SYSTEM is not recognized and, as noted previously, prevents eclipse from starting.
Changing that option to -addmods<LF>ALL-SYSTEM in eclipse.ini, made oxygen launch fine (<LF> stands for a new line).
Concerning other problems I tried creating symbolic links pointing to the jrt-fs.jar and the modules directory that made oxygen complain; all apparently seemed fine but the impression didn't last.
The problem in type resolution (Object, String, etc.) returned. I wasn't able to correct this. My settings for the jdk library and the modulepath are fine but no modules are loaded/displayed and this is a problem I've not already solved.
I hope that some of these information can be of help.