. Advertisement .
..3..
. Advertisement .
..4..
Please help me fix the warning: java lang module findexception module javafx controls not found.
I have two JPMS modules, modulea.jar and moduleb.jar, in two separate files. Javafx.controls module is required for Modulea. These modules must be used in the new layer, so I did:
ModuleFinder finder = ModuleFinder.of(modAPath, modBPath);
ModuleLayer parent = ModuleLayer.boot();
Configuration cf = parent.configuration().resolveAndBind(finder, ModuleFinder.of(), new HashSet<>());
ClassLoader scl = ClassLoader.getSystemClassLoader();
ModuleLayer newLayer = parent.defineModulesWithOneLoader(cf, scl);
I had assumed that the JDK modules would load automatically, but instead I receive this error message:
Exception in thread "main" java.lang.module.FindException: Module javafx.controls not found, required by modulea
at java.base/java.lang.module.Resolver.findFail(Resolver.java:889)
at java.base/java.lang.module.Resolver.resolve(Resolver.java:191)
at java.base/java.lang.module.Resolver.bind(Resolver.java:297)
at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:428)
at java.base/java.lang.module.Configuration.resolveAndBind(Configuration.java:230)
When I run java —list-modules, the following is the result:
...
javafx.base@9
javafx.controls@9
javafx.deploy@9
javafx.fxml@9
javafx.graphics@9
javafx.media@9
javafx.swing@9
javafx.web@9
How to solve the above problem? Thank you.
Solution:
There is no default loading of the
javafx.controls
module. By starting it with the--add-modules javafx.controls
option, you can force it into the boot layer. Try that way to solve your problem: java lang module findexception module javafx controls not found.