Link JavaFX in a jar

Answered

Hello, i would like to know how you link a local javafx in a jar.

Execute the main class in IntelliJ works, and a global path to a complete javafx library too.

I am not sure if i have to separate javafx.base, javafxgraphics etc or just use javafx in the command line.

What is the best location for the lib directory, inside or outside of the jar ?

MANIFEST.MF :

Manifest-Version: 1.0
Main-Class: helloworld.main.Main

HelloWorld.sh :

#!/bin/bash
java --module-path /lib/javafx --add-modules javafx.base,javafx.graphics -jar HelloWorld.jar

Terminal :

sh ./HelloWorld.sh
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found

 

 

0
2 comments

Hello,

What is the best location for the lib directory, inside or outside of the jar ?

Please see the related discussion at https://stackoverflow.com/questions/53533486/how-to-open-javafx-jar-file-with-jdk-11 .

Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.base not found

It seems that the configuration has not been fully patched. Try using the following command:

java --module-path /lib/javafx --add-modules javafx.controls,javafx.base,javafx.fxml,javafx.graphics,javafx.media,javafx.web -jar HelloWorld.jar

If you're using JavaFX SDK 14 together with OpenJDK 14, add one more option:

--add-exports javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED
0

I am still on the JDK 13 (and IntelliJ 2020), but nothing seems to work when the lib is inside of the jar.

The solution has been to move the lib outside of the jar and to normalize the paths because on Linux a start dot is required (i thought that it was only for a launch). The lib directory seems to be the best location for any jar file, and the root for the launcher, thus this command line works :

java --module-path ./lib/javafx --add-modules javafx.base,javafx.graphics -jar ./lib/HelloWorld.jar

Thank you for your help.

 

0

Please sign in to leave a comment.