I’m currently working on a Spring Boot project with a UI built using JavaFX. However, I’m facing issues with loading the JavaFX components. Despite following the setup instructions, the JavaFX parts are not loading correctly.
Here are the details of my setup:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>de.unimannheim.swt.ctf.ui</groupId>
<artifactId>ui</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!--JavaFx-->
<javafx.version>21.0.3</javafx.version>
<javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
</properties>
<!-- JavaFx -->
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<version>3.2.2</version>
</dependency>
<dependency>
<groupId>de.uni-mannheim.swt.pse</groupId>
<artifactId>ctf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpcore</artifactId>
<version>4.4.14</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.3</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>6.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.uni-mannheim.swt.pse</groupId>
<artifactId>ctf</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<version>3.2.2</version>
<scope>test</scope>
</dependency>
<!-- h2 database -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.2.224</version>
</dependency>
<dependency>
<groupId>de.unimannheim.swt.ctf.AiBot1</groupId>
<artifactId>AiBot1</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.unimannheim.swt.ctf.AiBot2</groupId>
<artifactId>AiBot2</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>de.unimannheim.swt.ctf.AiBot3</groupId>
<artifactId>AiBot3</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>${javafx.maven.plugin.version}</version>
<configuration>
<mainClass>de.unimannheim.swt.ctf.ui.Main</mainClass>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
<mainClass>de.unimannheim.swt.ctf.ui.Main</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>de.unimannheim.swt.ctf.ui.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I have to start the application that way:
java –module-path C:Users…javafx-sdk-21.0.3lib –add-modules javafx.controls,javafx.fxml,javafx.media -jar ui-1.0-SNAPSHOT.jar
Ofcause this is not like it should be.
Please fast bugfix, have to submit this project till tomorrow for the University 🙂
I tried all kinds of pom.xml modifications.
Here is my module-info.java
module ui {
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
requires javafx.media;
requires spring.boot;
requires com.fasterxml.jackson.databind;
requires spring.web;
requires java.xml;
requires java.desktop;
requires java.sql;
requires Aibot2;
requires Aibot1;
requires io.swagger.v3.oas.annotations;
requires jakarta.validation;
exports de.unimannheim.swt.ctf.ui.backendcopies.game.map;
exports de.unimannheim.swt.ctf.ui.backendcopies.data;
exports de.unimannheim.swt.ctf.ui.backendcopies.game.state;
exports de.unimannheim.swt.ctf.ui;
opens de.unimannheim.swt.ctf.ui;
opens de.unimannheim.swt.ctf.ui.mapeditor;
}