初始化引导层时发生错误java.lang.module.FindException - Java 9 + Eclipse Oxygen

时间:2018-01-02 11:09:18

标签: java eclipse maven java-9 java-module

我正在努力让我的Eclipse能够运行并调试一个简单的Java 9应用程序。我找到了一些建议,但我已经尝试了所有这些建议而没有任何成功。总而言之,以下是我在过去5小时内所阅读的内容:

  • 在Java 9中你不能使用package_name / something / * .jar(问题指向* .jar)
  • 您必须在eclipse.ini中设置Java 9
  • 您必须将module-info.java放在src目录下
  • 您设置了jre而不是jdk(首选项>已安装的JRE>添加...)

我发现的最接近的问题是How do I add modules to the Eclipse Oxygen module path for a project?,但没有接受答案,它似乎比当前的Eclipse版本旧。

事实上,我可以在Eclipse中成功编译(右键单击>运行为> Maven install ...)或直接从命令行使用mvn clean package install。不过,我可以直接从命令行运行应用程序,但我无法从Eclipse运行它。我认为这很有用,因为下一步将是调试。

简单的应用程序来自https://examples.javacodegeeks.com/core-java/java-9-httpclient-example/

我在原始应用程序pom中只进行了两次更改(有关详细信息,请参阅Failed to execute maven-compiler-plugin:3.6.1:testCompile when using java 9)。我刚刚将maven-compiler-plugin-version升级到3.7和maven-compiler-plugin我从1.9改为9然后我可以在Eclipse中编译它。

这是我当前的eclipse.ini,我手动更改了java版本:

-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/

以下是我成功运行该应用程序的方法:

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

假设我在Eclipse中设置了“--add-modules = jdk.incubator.httpclient”,我尝试了它没有成功:

enter image description here

  • 被修改

enter image description here

enter image description here

enter image description here

0 个答案:

没有答案
相关问题