Hi,
I created a program which uses JNI. I compiled it, generated header file, created a corresponding C program, and created dll for it.
Now I am placing the dll in the folder where my
Java program is e.g. my class com.ankur.FirstJNIExample is in d:\examples folder so I am placing this dll into d:\examples folder.
But when I run it I get following exception:
Exception in
thread "main" java.lang.UnsatisfiedLinkError: no FirstJNIExample.dll in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at com.ankur.FirstJNIExample.<clinit>(FirstJNIExample.java:8)
Could not find the main class: com.ankur.FirstJNIExample. Program will exit.
I read
here that if you place your dll in same folder then
you should be okay. Why it's not picking up my dll then?
Now to get going, I changed my code to this:
It doesn't give above exception as it finds the dll now. But now I am running into another exception:
Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\examples\FirstJNIExample.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(Unknown Source)
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.load0(Unknown Source)
at java.lang.System.load(Unknown Source)
at com.ankur.FirstJNIExample.<clinit>(FirstJNIExample.java:9)
Could not find the main class: com.ankur.FirstJNIExample. Program will exit.
I don't know which all dlls my FirstJNIExample.dll is dependent on. How can I know that? The dll file is unreadable in textpad.
I am not doing much in C program either:
What can be the issue?
Thanks.