1

I am using JNI (Java-Native-Interface) to acess some code that was written in c++. Everything works fine when I run the code from the command line but when I add the code to my Intellij project (class, header-file and dll) it gives the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Users\Robin\Desktop\egdb_example\end.dll: Can't find dependent libraries

My Java Code looks like this :

public class EndGame {

    public static native void openDataBase(int maxPieces, int buffer);

    public static native void test();

    public static native int lookUp(int condition, int BP, int WP, int K, int color);

    public static native void close();

    static {

        System.load("C:\\Users\\Robin\\Desktop\\egdb_example\\end.dll");

    }

    public static void main(String[] args) {

        System.out.println("Kleiner Test");
        openDataBase(8, 2000);
        int value = lookUp(0, 0, 0, 0, 0);
        close();
    }

}

I checked whether the path is actually correct running this piece of code

File test = new File("C:\\Users\\Robin\\Desktop\\egdb_example");

        for (File file : test.listFiles()){
            System.out.println(file.getName());
        }

which produces the outcome:

.git
.gitattributes
.gitignore
egdb.h
egdb.lib
egdb64.dll
egdb64.lib
egdb_example.cpp
egdb_example.vcxproj
egdb_example.vcxproj.filters
end.dll
EndGame.class
EndGame.h
EndGame.java
jni.h
jni_md.h
main.cpp
Readme.pdf
robin.cpp
robin.exe

Would appreciate any help

CheckersGuy
  • 117
  • 10

1 Answers1

0

Take a look here to see how to setup IntelliJ and CLion to debug code.

http://jnicookbook.owsiak.org/recipe-No-D002/

If you don't use CLion, simply skip that part and take a look solely at IntelliJ configuration.

Oo.oO
  • 12,464
  • 3
  • 23
  • 45