0

I am currently workin on an Application which is able to load modules provided in other jar files by using a custom classLoader

MyModule myModule = myModuleClassLoader.loadClass(f.getPath(), 
                    moduleConfig.classpath, MyModule.class);

This works perfectly fine, the modules can use all provided methods by the core application, and they can subscribe to events. Now the issues is, that if I have two modules for example, A and B, and I load both modules, they will be loaded as intended, but when I try to access a class from module A in module B, I get a ClassNotFoundException. I don't really have an idea why this is happening, because the CoreApplication is loading both modules, and all interaction from the modules to the core application work as intended.

Hovercraft Full Of Eels
  • 283,665
  • 25
  • 256
  • 373
  • Does this answer your question? [How do I resolve ClassNotFoundException?](https://stackoverflow.com/questions/17408769/how-do-i-resolve-classnotfoundexception) – Hovercraft Full Of Eels Jul 16 '23 at 22:58
  • Did you `export` the necessary packages in the module declarations? https://www.oracle.com/corporate/features/understanding-java-9-modules.html – Jim Garrison Jul 16 '23 at 23:13

1 Answers1

0

Found the solution myself. My custom ClassLoader used new UrlClassLoader() when I loaded a new Class, but you have to make sure to create One UrlClassLoader and use this one for every time when I use the loadClass method. By doing this, module A can now access the Classes from Module B an the other way arround.