-
Notifications
You must be signed in to change notification settings - Fork 26
Description
Originally our project pom had 3 openjfx dependencies declared in the pom. Worked great locally on windows.
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-web -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-swing -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
Then the package was assembled by linux based CI-pipeline and the javafx parts wouldn't work on windows anymore because of:
java.lang.RuntimeException: No toolkit found
at com.sun.javafx.tk.Toolkit.getToolkit(Toolkit.java:272)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:267)
at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:158)
at javafx.embed.swing.JFXPanel.lambda$initFx$1(JFXPanel.java:234)
at java.base/java.lang.Thread.run(Thread.java:830)
Okay, it's seems that openjfx only downloads binaries for the system its built on. Let's add windows classifier for out three dependencies.
<classifier>win</classifier>
Maven would download linux and windows binaries for our three dependencies javafx-controls, javafx-web, javafx-swing. That should do it.... Nope still wouldn't work on windows same error about toolkit not found. Here is the part about banging head against a wall for while. Eventually after long time It dawned that these dependencies depend on javafx-graphics. Even though we had declared windows classifier in our pom it wouldn't affect openjfx's dependencies. The solution was to add all of the openjfx's dependencies by hand to our pom and add the classifier by hand.
The final pom that worked looked liked this. To ease other peoples suffering please add to openjfx documentation that you will need to manually add openjfx's internal dependencies to your pom and apply classifier for every platform (mac, linux, windows) you wish to support .
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-base -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-base</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-graphics -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-graphics</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-media -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-media</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-controls -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-web -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-web</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-swing -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-swing</artifactId>
<version>${javafx.version}</version>
<classifier>win</classifier>
</dependency>