1

I can't have the cache library in "C:\Users\anpaumal\". I would like to redirect it to C:\Program Files\OpenJdk

This is my pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven- 
    4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>16</version>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.release>11</maven.compiler.release>
        <javafx.version>16</javafx.version>
        <javafx.maven.plugin.version>0.0.8</javafx.maven.plugin.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>${javafx.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>${javafx.version}</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <release>${maven.compiler.release}</release>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>${javafx.maven.plugin.version}</version>
                <configuration>
                    <mainClass>org.openjfx.hellofx.App</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

I'm getting this error code:

java.lang.UnsatisfiedLinkError: C:\Users\anpaumal\.openjfx\cache\16\prism_d3d.dll

The DLL is blocked by a safety principle (can't execute DLLs from there), which I'm not allowed to change...

I've tried to configure run command like this:

-Djavafx.cachedir="C:\Program Files\OpenJDK"
-Djavafx.verbose=true

And like this:

-Djavafx.cachedir=C:\Program Files\OpenJDK
-Djavafx.verbose=true

I've also tried to set the environment variabes in run configurations (using eclipse): javafx.cachedir to C:\Program Files\OpenJDK

But I will always get the same error code:

java.lang.UnsatisfiedLinkError: C:\Users\anpaumal\.openjfx\cache\16\prism_d3d.dll

Is it possible to do what I want to do?

Slaw
  • 37,820
  • 8
  • 53
  • 80
Paul
  • 123
  • 5
  • Looking at the source code, setting the `javafx.cachedir` system property is a correct solution. Though I would think writing to `C:\Program Files\OpenJDK` would require admin privileges; perhaps that's part of the problem. – Slaw May 25 '23 at 07:39
  • No there are no specific restrictions on that specific directory, thats why I would like to store the DLLs there. – Paul May 25 '23 at 08:28
  • Maybe use jmod files [from gluon](https://gluonhq.com/products/javafx/) (perhaps with jlink) instead of Maven dependencies for JavaFX. That way, perhaps the JavaFX system can load the libraries directly from the modules without trying to copy them to a cache directory. For details on the loading process see the [`NativeLibLoader` code](https://github.com/openjdk/jfx/blob/70953643a9dc05c76924fc4c602ee39038d71295/modules/javafx.graphics/src/main/java/com/sun/glass/utils/NativeLibLoader.java#L119). Using a JDK which already includes JavaFX such as Liberica "Full JDK" might work. – jewelsea May 26 '23 at 03:57
  • This worked for me: `-Djavafx.cachedir=C:\dev\openjfx-cache` set as a [VM argument in Idea](https://stackoverflow.com/a/67960821/1155209), – jewelsea May 26 '23 at 04:13
  • I also tried with Liberica "Full JDK" and it did not need to use the cache directory, it was able to directly load the native libraries from the JavaFX modules in the Liberica JDK. I did not need to modify the Maven dependencies to remove the JavaFX dependencies to do that, it seems that the JavaFX modules in the Liberica JDK override the modules defined in Maven (AFAICT). – jewelsea May 26 '23 at 04:35

0 Answers0