I have to call a dll method and I don't have the source code from dll, I was reading about JNI and understood that you should have the source to input the JNI library in the code (.h).
My second shoot is JNA, but I am getting the same error, although you don't have to change anything in DLL.
I created two classes to test:
interface:
package icom;
import com.sun.jna.Library;
public interface IConectorT extends Library {
int StartConector(byte[] conectorStatus, String icomPath);
}
DLL method call:
package icom;
import com.sun.jna.Native;
public class ConectorTJna {
public static void main(String args[]) {
IConectorT lib = (IConectorT) Native.loadLibrary("ConectorT", IConectorT.class);
int teste = lib.StartConector(null, "C:\\ICOM");
System.out.println("RESULT: " + teste);
}
}
When I call the lib.StartConector method I get this:
Exception in thread "main" java.lang.UnsatisfiedLinkError: Error looking up function 'StartConector': The specified procedure could not be found. at com.sun.jna.Function.(Function.java:179) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:350) at com.sun.jna.NativeLibrary.getFunction(NativeLibrary.java:330) at com.sun.jna.Library$Handler.invoke(Library.java:203) at $Proxy0.StartConector(Unknown Source) at icom.ConectorTJna.main(ConectorTJna.java:10)
dumpbin /exportsto find out the names of functions, hence knowing what package name of the Java stub is expected. But you won't know the full signatures, i.e. what parameters and their types is expected. Nobody will tell you that. You seem to have a little clue, given that you are already attempting to call someStartConectorwith some params.