Exception while importing dl4j into my project

I’m trying to use dl4j in my project which runs on openjdk- and I use gradle to manage my dependencies. The project builds with no errors but when the code is executed it crashes immediately with the error
“java.lang.module.InvalidModuleDescriptorException: Provider class com.twelvemonkeys.imageio.plugins.jpeg.JPEGImageReaderSpi not in module”

I haven’t really worked with java modules since I have only used java 8 so far but to me this looks like its missing a bunch of packages and I don’t know what to do about it. Do I need to put something into the module-info.java file? I have not used any dl4j classes or methods so far in the project.
Thanks in advance.

Here is how I added the dependencies:
" implementation group: ‘org.deeplearning4j’, name: ‘deeplearning4j-core’, version: ‘1.0.0-beta6’ "
" implementation group: ‘org.nd4j’, name: ‘nd4j-cuda-10.2-platform’, version: ‘1.0.0-beta6’ "

This looks quite suspicious. We don’t load anything until you actually start using ND4J.

Are you in some kind of OSGI or other IOC environment?

Also, beta6 is over a year old now. If you are just starting out, I suggest you go with beta7.

To answer your question, no, I am not using any of these environments. After doing some testing I think the issue is the existence of the module-info file in my source folder. When I delete it there is no problem. I do need the module-info however because I also want to use javafx in my project and I have to include the modules.

Do you know why it fails when the module-info is included? As I said, I’m a bit new to modular programming in java :slight_smile:

The problem you are running appears like into isn’t directly related to DL4J, but to one of the (optional) dependencies.

If you don’t need image processing, I guess you can just exclude the dependency and it will probably work.

As for a workaround, my best guess here is that javafx finds it via the ServiceLoader interface, but can’t actually access the class because your module-info doesn’t actually declare that it requires access to it. So try declaring that you need access to that package?