- 1 year ago
Error when building runtime image using javafx-maven-plugin on Windows 10 with uber-jar dependencies (javafx-graphics)
When building a runtime image using the javafx-maven-plugin
and encountering an error related to the javafx-graphics
dependency, it could be due to the exclusion of certain modules by the uber-jar
configuration. The javafx-graphics
module is required for JavaFX applications, and its absence can lead to errors during runtime image creation.
To resolve this issue, you can try the following steps:
Check
maven-shade-plugin
Configuration:
If you're using themaven-shade-plugin
or a similar plugin for creating the uber-jar, ensure that you're not excluding thejavafx-graphics
module or any other necessary JavaFX modules. Review the configuration of the plugin and remove any exclusions related to JavaFX.Verify
javafx-maven-plugin
Configuration:
Ensure that thejavafx-maven-plugin
configuration in yourpom.xml
file is correctly set up to include the JavaFX modules required for your application. Here's an example of a minimaljavafx-maven-plugin
configuration that includes the necessary modules:xml<build>
<plugins>
<plugin>
<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.3</version>
<configuration>
<mainClass>com.example.Main</mainClass>
<jlinkZip>${project.build.directory}/jlink.zip</jlinkZip>
<jlinkImageName>myapp</jlinkImageName>
<jlinkModules>
<module>javafx.controls</module>
<module>javafx.fxml</module>
<!-- Add other required modules here -->
</jlinkModules>
</configuration>
</plugin>
</plugins>
</build>
Make sure that the required JavaFX modules, including
javafx-graphics
, are listed under the<jlinkModules>
configuration.Verify JavaFX Dependencies:
Ensure that the JavaFX dependencies in yourpom.xml
file are correctly specified and include the necessary modules. For example:xml<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>16</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>16</version>
</dependency>
<!-- Add other required JavaFX dependencies here -->
</dependencies>
Make sure that the required JavaFX modules, including
javafx-graphics
, are included in the dependencies.
By ensuring that the necessary JavaFX modules are correctly configured and included in the build process, you should be able to resolve the error related to the javafx-graphics
dependency and successfully build the runtime image using the javafx-maven-plugin
.