1

Creating a simple HelloWorld application with JavaFX 11 and Maven with only this dependency:

<dependencies>
    <dependency>
        <groupId>org.openjfx</groupId>
        <artifactId>javafx-controls</artifactId>
        <version>11</version>
    </dependency>
</dependencies>

This results in this dependency tree:

[INFO] --- maven-dependency-plugin:2.8:tree (default-cli) @ javafx-module-test ---
[INFO] ch.sahits.test:javafx-module-test:jar:1.0-SNAPSHOT
[INFO] \- org.openjfx:javafx-controls:jar:11:compile
[INFO]    +- org.openjfx:javafx-controls:jar:linux:11:compile
[INFO]    \- org.openjfx:javafx-graphics:jar:11:compile
[INFO]       +- org.openjfx:javafx-graphics:jar:linux:11:compile
[INFO]       \- org.openjfx:javafx-base:jar:11:compile
[INFO]          \- org.openjfx:javafx-base:jar:linux:11:compile

As you can guess from the above output I run this on a Linux machine which left me with an bad feeling regarding creating executable jar files that are portable to other OS. Therefore I went ahead and created such a jar file using the assembly plugin: Executable jar layout As you can see in the above image of the jar's content there are native libraries included. For Windows this would probably be some dlls.

How can we create an executable jar file for a JavaFX application that can be run anywhere?

The one way I could imagine is to require the OpenJFX runtime being installed on the target machine, so that it does not need to be bundled in the jar, but this is something to be avoided as it is very user unfriendly.

hotzst
  • 7,238
  • 9
  • 41
  • 64
  • Check this [question](https://stackoverflow.com/questions/52653836/maven-shade-javafx-runtime-components-are-missing). – José Pereda Nov 10 '18 at 11:25
  • @JoséPereda Thanks. As I understand it the classifier is only needed the javafx-graphics dependency but not any other (i.e. javafx-fxml, javafx-media)? – hotzst Nov 10 '18 at 12:54
  • The classifier is required _if_ the jar is different (for instance, `javafx.graphics` has different packages, gtk classes only on Linux), or if it requires native libraries (`javafx.media` has native libraries). – José Pereda Nov 10 '18 at 12:57

0 Answers0