Hey everybody,

what is the recommended way for loading shared libraries required by JFX? I have to decide between "java.library.path" and some internal path determination of jfx.

My background: I'm a software developer of Cryptomator, a Java GUI app to encrypt files using JFX. We are shipping the app with a custom JRE created with jlink. A while ago, I learned on this mailing list that the recommended way of shipping the required shared libs is by backing them into the custom JRE using jmods. We changed our CI builds and thought everything is working now, but another problem arose. Depending on the used JDK, on Windows the shipped native libs were not used, but the ones found in the system PATH variable. During investigation, we also looked in the jfx project at the class "NativeLibLoader.class", which handles the loading of the shared libraries. (Source: https://github.com/openjdk/jfx/blob/19.0.2.1%2B1/modules/javafx.graphics/src/main/java/com/sun/glass/utils/NativeLibLoader.java)

The loading precedence is according to inline documentation (line 117 ff) the following:

// The search order for native library loading is:
// - try to load the native library from either ${java.home}
//   (for jlinked javafx modules) or from the same folder as
//   this jar (if using modular jars)
// - if the native library comes bundled as a resource it is extracted
//   and loaded
// - the java.library.path is searched for the library in definition
//   order
// - the library is loaded via System#loadLibrary
// - on iOS native library is staticly linked and detected from the
//   existence of a JNI_OnLoad_libraryname funtion

BUT,  2 lines below there is a FIXME comment stating to eventually discard the first step (load from java.home or jar). Hence my question: Should we directly switch to the second or third step or does the comment target something different?

Kind regards,

Armin


PS: Regarding the the problem using different JDKs: Azul offers its Zulu JDK in a "JFX flavor", but this flavor is not directly compatible with the NativeLibLoader of JFX. For more details, see https://forums.foojay.io/forums/topic/jdkfx-fx-app-with-custom-jre-created-with-jlink/

Reply via email to