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.
1 Answer 1
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.
exportthe necessary packages in the module declarations? oracle.com/corporate/features/understanding-java-9-modules.html