I am struggling to get my Eclipse able to run and debug a simple Java 9 application. I have found several suggestions and I have tried all of them without any success. To summarize, here are all I have read in the last 5 hours:
- in Java 9 you can't use package_name/something/*.jar (the issue is pointed to be *.jar)
- you must setup Java 9 in eclipse.ini
- you must place module-info.java under src directory
- you setup jre instead of jdk in (Preference>Installed JREs>Add...)
The closest question I found to mine is How do I add modules to the Eclipse Oxygen module path for a project? but without accepted answer and it seems to be older than current Eclipse version.
In fact, I can compile successfully both in Eclipse (right click>run as>Maven install...) or using mvn clean package install straight from command line. Nevertheless, I can run the application straight from command line but I can't run it from Eclipse. I do consider this usefull since the next step will be debug.
The simple application is downlowaded from https://examples.javacodegeeks.com/core-java/java-9-httpclient-example/
I made only two changes in the original application pom (see Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9 for deeper details). I just upgraded maven-compiler-plugin-version to 3.7 and maven-compiler-plugin I changed from 1.9 to 9 and then I can compile it in Eclipse.
Here is my current eclipse.ini where I manually changed the java version:
-startup
plugins/org.eclipse.equinox.launcher_1.4.0.v20161219-1356.jar
--launcher.library
C:\Users\dca\.p2\pool\plugins\org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.551.v20171108-1834
-product
org.eclipse.epp.package.jee.product
-showsplash
org.eclipse.epp.package.common
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vm
C:\Program Files\Java\jre-9.0.1\bin
-vmargs
-Dosgi.requiredJavaVersion=1.9
-Dosgi.instance.area.default=@user.home/eclipse-workspace
-XX:+UseG1GC
-XX:+UseStringDeduplication
--add-modules=ALL-SYSTEM
-Dosgi.requiredJavaVersion=1.9
-Xms256m
-Xmx1024m
--add-modules=ALL-SYSTEM
-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/
Here is how I successfully run the application:
C:\_EclipseJava9\WSs\ws\java9-http-client\target>java -jar --add-modules=jdk.incubator.httpclient http_client-0.0.1-SNAPSHOT.jar
WARNING: Using incubator modules: jdk.incubator.httpclient
Running synchronous HTTP Client examples
Assuming I shoud setup "--add-modules=jdk.incubator.httpclient" in Eclipse I tried it without success:
- Edited