title: How to load a dll and call a JNI method in Tomcat?
body: <p>I have successfully called a method contained in a dll from a Java program using JNI. This is what i do:</p>
  
  <pre><code>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
    }
  }
  </code></pre>
  
  <p>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.</p>
  
  <p>This is the error I get: </p>
  
  <pre><code>java.lang.UnsatisfiedLinkError: com.example.MyClass.foo()
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>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).</p>