transitive dependencies in Eclipse Plugin-Project with Java 9

拈花ヽ惹草 提交于 2020-01-02 06:54:05

问题


It seems, that in my Eclipse Oxygen 3 transitive dependencies are not resolved in Plugin-Projects. Consider the following Project with A depending solely on B, and B depending on C: While running A in JDK 1.8 turns out fine (as expected), in JDK 9 I get the well known

Exception in thread "main" java.lang.NoClassDefFoundError: c/C
    at b.B.<init>(B.java:9)
    at a.A.main(A.java:8)
Caused by: java.lang.ClassNotFoundException: c.C
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:582)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:185)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:496)
    ... 2 more

I know, I have not declared any modules but I thought, omitting them just keeps the project as it is, even in JDK 9. When I import project C directly in the A MANIFEST.MF, then all works as in JDK 1.8. So how to get the projects running, if possible without declaring modules?


回答1:


You can modify the MANIFEST.MF in project B to reexport its dependency to project C:

  • open the MANIFEST.MF from project B in the MANIFEST-Editor
  • switch to the Dependencies tab
  • select the dependency to project C and click "Properties..."
  • select "Reexport this dependency"

Keep in mind that this change will also make classes from project C available in project A, creating an explicit dependency from A to C when using those classes.



来源:https://stackoverflow.com/questions/49479262/transitive-dependencies-in-eclipse-plugin-project-with-java-9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!