1

I'm using JDEPS to list the dependencies of libraries to ensure they are satisfied.

I've recently upgraded from Apache POI v4.1.1 to v5.0.0, where JigSaw modules were added.

Previously, the following command would output the dependencies:

jdeps --multi-release 11 poi-scratchpad-4.1.1.jar

But now using v5.0.0, I'm getting:

jdeps.exe --multi-release 11 poi-scratchpad-5.0.0.jar
Exception in thread "main" java.lang.module.FindException: Module commons.math3 not found, required by org.apache.poi.scratchpad
        at java.base/java.lang.module.Resolver.findFail(Resolver.java:894)
        at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
        at java.base/java.lang.module.Resolver.resolve(Resolver.java:140)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:422)
        at java.base/java.lang.module.Configuration.resolve(Configuration.java:256)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsConfiguration$Builder.build(JdepsConfiguration.java:564)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.buildConfig(JdepsTask.java:603)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:557)
        at jdk.jdeps/com.sun.tools.jdeps.JdepsTask.run(JdepsTask.java:533)
        at jdk.jdeps/com.sun.tools.jdeps.Main.main(Main.java:49)

I have the commons-math3 library, but even when I include it via the -classpath argument, I'm still getting the same issue.

Naman
  • 27,789
  • 26
  • 218
  • 353
Jakg
  • 922
  • 12
  • 39

1 Answers1

1

Using --module-path instead of the -classpath option for the module to be resolved for commons-math3-3.6.1.jar should work for you.

In practice, you can detail all the dependencies into a single folder for simplicity and then treat that as modulepath such as following:

enter image description here

In the above image, I have created a dependencies folder that includes the .jars for all dependent libraries for poi-scratchpad. Further executing the following command from the same directory works:

jdeps --module-path dependencies poi-scratchpad-5.0.0.jar 
Naman
  • 27,789
  • 26
  • 218
  • 353
  • thankyou, if I try the ``--module-path`` I get a different error, which is... something? "Exception in thread "main" java.lang.module.FindException: Unable to derive module descriptor for batik-script-1.13.jar" – Jakg Jan 21 '21 at 17:37
  • Currently, it's not possible to derive the automatic module name from certain artifacts for example see [this](https://stackoverflow.com/questions/46501388/unable-to-derive-module-descriptor-for-auto-generated-module-names-in-java-9). For those specifically, you can still choose to keep them on the `--class-path` and use both the properties (modulepath and classpath). – Naman Jan 21 '21 at 17:40
  • @Jakg for your specific case, it's also worth reading a case when provider classes are not found resulting in unable to derive the automatic module name, as detailed in this [Q&A](https://stackoverflow.com/questions/54682417/java-11-unable-to-derive-module-descriptor) – Naman Jan 21 '21 at 17:57
  • do you have an example of mixing the module-path and classpath arguments using the POI dependencies? For me it only gives an error. – Jakg Jan 13 '22 at 12:08
  • My current thought is that it's a problem wit the batik library - when I update to a newer version, I get a different error regarding another libraries module name. But I'm unsure of what the error is, or how I can fix it in someone else's dependency. – Jakg Jan 13 '22 at 16:41