custom jre with javaFX 11

旧巷老猫 提交于 2019-12-02 00:20:34

If you go to this link, you will notice there are two flavors for the JavaFX distribution for each platform:

The JavaFX SDK is the one you are using as:

export PATH_TO_FX=/path/to/javafx-sdk-11/lib

and if you check the files under lib, these are jars.

The JavaFX jmods on the other side contains the jmod format.

And if you read about the jmod format here:

For most development tasks, including deploying modules on the module path or publishing them to a Maven repository, continue to package modules in modular JAR files. The jmod tool is intended for modules that have native libraries or other configuration files or for modules that you intend to link, with the jlink tool, to a runtime image.

In other words, if you use javac or java to run your jar or module you can use the SDK, but if you are using jlink to create a custom JRE, you need the jmod version.

Once you have downloaded the jmods, unzip them and create this variable:

export PATH_TO_FX_JMOD=/path/to/javafx-jmods-11/

Now you can create the JRE:

jlink --module-path %PATH_TO_FX_JMOD%;mods --add-modules=com.javafxdemo --output FXJRE

and run:

FXJRE/bin/java -m com.javafxdemo/com.javafxdemo.JavaFXDemo

Ubuntu 18.04, Java 11, Netbeans 11.0: I had the same error as you because I set up Library JavaFX11 using the jars in /usr/share/openjfx/lib which are from the Ubuntu openjfx 11.0.2+1-1~18.04.2 package. I thought because the same jars were in this directory I could use it but the javafx-sdk-11.0.2/lib directory you get by downloading JavaFX Linux SDK from https://gluonhq.com/products/javafx/ contains many other library files (like libglass.so) which ARE needed.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!