Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/354.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在Tomcat中加载dll并调用JNI方法?_Java_Eclipse_Tomcat_Dll_Java Native Interface - Fatal编程技术网

Java 如何在Tomcat中加载dll并调用JNI方法?

Java 如何在Tomcat中加载dll并调用JNI方法?,java,eclipse,tomcat,dll,java-native-interface,Java,Eclipse,Tomcat,Dll,Java Native Interface,我已经成功地使用JNI从Java程序调用了dll中包含的方法。我就是这么做的: 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();

我已经成功地使用JNI从Java程序调用了dll中包含的方法。我就是这么做的:

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
  }
}
现在我也在尝试做同样的事情,但是在一个使用Tomcat的web应用程序中。我尝试过使用绝对路径和相对路径,将dll放在WEB-INF/lib中,在Properties->Java Build Path中选择它,但它不起作用。顺便说一下,我正在研究Eclipse

这是我得到的错误:

java.lang.UnsatisfiedLinkError: com.example.MyClass.foo()
编辑:


显然,它会找到dll,因为如果我将名称更改为不存在的名称,我会收到一个错误,告诉我无法找到dll。据我所知,它在dll中找不到foo()方法,这很奇怪,因为正如我前面所说,同一个dll在一个简单的java程序(而不是web应用程序)中工作。

失败是因为它无法引用路径?或者它可以引用路径,但无法加载?你能显示错误吗?我已经添加了错误get@PabloRP您尝试在Java构建路径中的何处添加它?可能与