Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure OpenJFX 11 to extract its DLLs into a different user-specified directory?

Is there a way to configure OpenJFX 11 to extract their DLLs into a different user-specified directory?

While trying to migrate an existing Java 10/Maven project to Java 11, I tried using OpenJDK 11. To get the code build working, I needed to add the JavaFX JARs into the Maven pom.xml configuration files (because JavaFX is no longer a built-in part of Java 11).

However, at runtime I discovered errors due to OpenJFX extracting DLL files into a user directory and then having access failures (see errors, below). I've had many projects over the years that had errors when working with the C:\Users* directories (from Microsoft Windows interfering with file locks and directory permissions, anti-virus scans, etc), so I try to avoid those directories whenever possible. The Java project works properly under Java 10 on Windows 7 and on RedHat 7, which seems to imply that the Oracle's JavaFX 10 JARs are not extracting DLLs into the C:\Users* directories. OpenJFX seems to have no troubles writing the DLLs into those directories, but it cannot read those same files afterwards.

I am running on Microsoft Windows 7 Professional 64-bit with service-pack 1. I haven't tried running on Linux yet with OpenJDK 11 and OpenJFX, but I would imagine OpenJFX would try to extract its DLLs on that platform as well.

Example runtime Java errors caused by OpenJFX:

Loading library prism_d3d from resource failed: java.lang.UnsatisfiedLinkError: C:\Users\MyUserName\.openjfx\cache\11\prism_d3d.dll: Access is denied

java.lang.UnsatisfiedLinkError: C:\Users\MyUserName\.openjfx\cache\11\prism_d3d.dll: Access is denied

Loading library prism_sw from resource failed: java.lang.UnsatisfiedLinkError: C:\Users\MyUserName\.openjfx\cache\11\prism_sw.dll: Access is denied

java.lang.UnsatisfiedLinkError: C:\Users\MyUserName\.openjfx\cache\11\prism_sw.dll: Access is denied

Graphics Device initialization failed for : d3d, sw

Error initializing QuantumRenderer: no suitable pipeline found

java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found
like image 761
navySV Avatar asked Nov 19 '18 21:11

navySV


1 Answers

Summary of the previous discussion and the linked resources

Since OpenJFX 12 you can use the system property javafx.cachedir to tell OpenJFX where to extract it's native libraries. Take care not to use camel-case notion in the 'cacheDir' part of the system property (like used in previous comments and in the pull-request comments).

See this Pull-Request for the details.

In versions prior 12, OpenJFX will extract it's native libraries to a fixed path based on user.home (System.getProperty("user.home") + "/.openjfx/cache/" + jfxVersion).

There are two ways to modify the path OpenJFX will use as cache location

  1. Provide the native libraries by yourself and store it in a custom location. Then use the java.library.path system property to tell OpenJFX to load it from your custom location (this will avoid the extraction into the fixed cache location).
  2. Modify user.home to modify the cache location.

See this Code for details.

like image 197
lgraf Avatar answered Sep 21 '22 13:09

lgraf