2

I have a project where dependencies were designed based on java 8, I'm using java 9 modules. I keep getting errors related to multiple exports.

java: java.lang.reflect.InvocationTargetException
Modules nd4j.common and nd4j.api export package org.nd4j.linalg.util to module jai.imageio.core

Do I need to map out every dependency tree, find the duplicates and make exclusions? Some dependencies have upwards of 12 dependencies that also have their own dependencies. Is there a better way? Java 9 modules are becoming a huge needless headache if not.

Here are the libraries I'm using: Deeplearning4j-core, Deeplearning4j-ui, deeplearning4j-zoo, nd4j-native-platform, javacv, lombok, javafx-controls, javafx-fxml, javafx-media, controls-fx, formsfx-core

I tried creating an Excel spreadsheet of all my dependencies' dependencies, found the ones that were duplicates, and made the appropriate exclusions in pom.xml. I'm still getting multiple export errors but they are now libraries that I'm not even sure where they are because they aren't ones I've imported but rather a child dependency somewhere that is in common with another child somewhere.

Thank you for looking!

Borel
  • 29
  • 4
  • 4
    Honestly, if your dependencies are not modular, it may be more effort than it's worth to use modules. The only dependency I see in your list that "must" (a warning is emitted otherwise since JavaFX 16, but it still works afaik) be on the module-path is JavaFX (9+). Note that code in the unnamed module (i.e., code on the class-path) can use code in named modules (i.e., code on the module-path), but not vice versa. That may matter if you deploy using e.g., `jpackage`, where you can make a run-time image with all the modular code, but leave your and other non-modular code on the class-path. – Slaw Jan 10 '23 at 01:51
  • 1
    (and regarding code in named modules not being to use code in unnamed modules, I mean named modules can't use code in unnamed modules "directly"; if I'm not mistaken, named modules can still load service-providers from unnamed modules, if they use the correct `ServiceLoader.load` method and the appropriate `uses` directives are declared) – Slaw Jan 10 '23 at 02:23
  • 1
    Thank you, that answers my question. If you would like to submit one I can select it. I got rid of module-info.java, removed modular dependencies from pom, and instead added a pointer to those in the vm options. Everything is working fine now. – Borel Jan 10 '23 at 02:25
  • Note modular code can still be placed on the class-path. They stop being named modules, but otherwise should work normally (except possibly for some edge cases). So, it may have been unnecessary to remove _all_ modular dependencies from your POM. – Slaw Jan 10 '23 at 02:31
  • You are right about leaving it in the pom. – Borel Jan 10 '23 at 02:46
  • @Borel You too can post and accept an Answer to your own Question. – Basil Bourque Jan 10 '23 at 08:15

0 Answers0