I have successfully called a method contained in a dll from a Java program using JNI. This is what i do:
public class MyClass {
static {
System.load("C:/Users/pabloruiz/library.dll");
System.loadLibrary("library"); // This works too if the dll is in the Java Build Path
}
public native void foo();
public static void main(String[] args) {
new MyClass().foo(); // invoke the native method
}
}
Now I'm trying to do the same but in a web app with Tomcat. I have tried using absolute paths and relative paths, placing the dll in WEB-INF/lib, selecting it in Properties->Java Build Path but it doesn't work. By the way, I'm working on Eclipse.
This is the error I get:
java.lang.UnsatisfiedLinkError: com.example.MyClass.foo()
EDIT:
Apparently, it founds the dll because if I change the name to something that doesn't exist I get an error telling me that the dll couldn't be found. From what I understand it can't find the method foo() inside the dll, which is weird because, as I said above, that same dll works from a simple java program (not a web app).