'Can´t run JavaFX application outside ide
I want run JavaFX application with module but dont know how to do. I tried several times but i never got it. I use Eclipse, and export the proyect with the first selected option.
module MiProgramaInterfaz {
requires javafx.controls;
requires javafx.fxml;
requires java.xml;
requires javafx.base;
opens controlador to javafx.graphics, javafx.fxml, javafx.base;
opens modelo.clases to javafx.graphics, javafx.fxml, javafx.base;
opens principal to javafx.graphics, javafx.fxml, javafx.base;
}
The last command i tried was this
java -p app.jar -m MiProgramaInterfaz/principal.Main
but i got this error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.fxml not found, required by MiProgramaInterfaz
I tried steps from https://openjfx.io/openjfx-docs/#install-javafx but nothing
Solution 1:[1]
You have two options To run a JavaFX application:
- Use a Java runtime embedding JavaFX, like the SDK provided by Gluon or the JDK/JRE from Azul. Then the command you tried should work. You can check if JavaFX is included in the runtime by running
java --list-modules
. - Use a standard Java runtime. Then you must must add to the module path (
-p
option) the jars containing the modules you need, likejavafx-controls-17.0.2-linux.jar
.
When running a modular application, a jar must contain only 1 module. So building a fat jar file like you tried won't work. Select "copy required libraries to a sub-folder" and either use option 1 without using the sub-folder, or use option 2 and add the subfolder to your module path.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |