"Cannot Load Library:" when I try to access a .dll file

  c++, java, java-native-interface

I’m trying to load a library called "change.dll" which sits in the same directory as my file "C.java" here’s the code of that file.

package Main.C;

import java.io.File;

public class C {

    public static native long change(int width, int height);

    private static final String absolute = new File("resolution/C/change").getAbsolutePath();

    static {

    public static void main(String[] args) {
        C.change(1024, 768);


When I run the code I get this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Can't load library: {directory of .dll}
    at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2620)
    at java.base/java.lang.Runtime.load0(Runtime.java:765)
    at java.base/java.lang.System.load(System.java:1835)
    at Main.C.C.<clinit>(C.java:12)

The directory points exactly to the file, I’ve tried changing "System.loadLibrary()" to "System.load()" and also adding .dll to the end of change in the directory but neither sufficed. Any help is appreciated

Source: Windows Questions C++