I have two JPMS modules:
In module-a I have something like:
public class MyAppplication extends Application {
....
public static void addCss(String path) {
stage.getScene().getStylesheets().add(path);
}
}
In module-b I have CSS file which I want to add to MyApplication
. How to do it in code in module-b? I can't understand how to pass path from another module.
I mean in module-b:
...
MyApplication.addCss(???);
...
EDIT
In OSGi I used the following solution in bundle-b
(assuming, that module-a was bundle-a, and module-b was bundle-b):
String pathInBundleB = "com/foo/package-in-bundle-b/file.css"
Bundle bundleB = FrameworkUtil.getBundle(this.getClass()).getBundleContext().getBundle();
URL cssFileUrl = bundleB.getEntry(pathInBundleB);
MyApplication.addCss(cssFileUrl.toString());
I found the solution with the help of @AlanBateman.
Assuming, that css file is in com/foo/some-package/file.css
I use the following code in module-b:
package com.foo.some-package;
public class SomeClass {
public void init() {
MyApplication.addCss(this.getClass().getResource("base.css").toString());
}
}
Besides, in module-info of module-b I have:
opens com.foo.some-package to module-a;