尝试解析 OpenJFX jmods 时 jdeps 命令失败

jdeps command failing when trying to resolve OpenJFX jmods

我正在尝试 运行 在使用 OpenJFX 的项目上执行 jdeps 命令,但它一直失败。

我正在使用的命令已尽可能简化:

jdeps --module-path Y:\javafx-jmods-11.0.2 --add-modules javafx.base Test.jar

javafx-jmods-11.0.2 是包含 OpenJFX jmod 文件的目录。

当我 运行 这个命令时,我得到错误:

Exception in thread "main" java.lang.module.FindException: Module javafx.base not found
    at java.base/java.lang.module.Resolver.findFail(Resolver.java:877)
    at java.base/java.lang.module.Resolver.resolve(Resolver.java:128)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:411)
    at java.base/java.lang.module.Configuration.resolve(Configuration.java:245)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration.<init>(JdepsConfiguration.java:117)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:563)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:589)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:543)
    at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:519)
    at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)

有没有人有任何想法或建议,为什么找不到位于 Y:\javafx-jmods-11.0.2 中的 javafx.base 模块?

通常,当您收到错误时:

java.lang.module.FindException: Module ... not found

这意味着模块路径错误(没有有效路径)或您提供的路径不包含所需的模块。

正如您在 的答案中所见:

As explained here: http://openjdk.java.net/jeps/261#Packaging:-JMOD-files:

JMOD files can be used at compile time and link time, but not at run time. To support them at run time would require, in general, that we be prepared to extract and link native-code libraries on-the-fly.

什么意思不能将 jmods 与 jdeps 结合使用。

解决方案

在这种情况下,解决方案很简单:使用 JavaFX SDK 中的 jar,而不是 jmods:

jdeps --module-path Y:\javafx-sdk-11.0.2\lib --add-modules javafx.base Test.jar