我正在研究狐猴工具,我正在处理一些问题。
当我执行代码时,java会抱怨
Exception in thread "main" java.lang.UnsatisfiedLinkError: no indri_jni in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1886)
at java.lang.Runtime.loadLibrary0(Runtime.java:849)
at java.lang.System.loadLibrary(System.java:1088)
at lemurproject.indri.indriJNI.<clinit>(indriJNI.java:109)
at lemurproject.indri.IndexEnvironment.<init>(IndexEnvironment.java:39)
at indritest.main(indritest.java:9)这是我的密码
import lemurproject.indri.*;
public class indritest
{
public static void main ( String[] args )
{
try {
String [] stopwords = {"a", "an", "the", "of"};
IndexEnvironment env = new IndexEnvironment();
env.setStoreDocs(true);
env.setStopwords(stopwords);
env.create("aaa");
env.addFile("trekfile.txt", "booomer.txt");
env.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}我正在使用jdk 1.8.0_11 x64bit,windows 7终极x64bit,indri5.7 x64bit,eclipse x64bit。
.........................................................................................................................编辑:-
我使用了RALF 给出的解决方案,现在我的控制台显示了这个Bug。在我的控制台中打印了System.getProperty("java.library.path")之后,我得到了这个输出。indri_jni.dll已经存在于system32文件夹中。
我的密码。
import lemurproject.indri.*;
public class indritest
{
public static void main ( String[] args )
{
try {
System.out.println(System.getProperty("java.library.path"));
//System.loadLibrary("indri_jni");
String [] stopwords = {"a", "an", "the", "of"};
IndexEnvironment env = new IndexEnvironment();
env.setStoreDocs(true);
env.setStopwords(stopwords);
env.create("aaa");
env.addFile("trekfile.txt", "booomer.txt");
env.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}我的控制台出来了。
C:\Program Files\Java\jdk1.8.0_11\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\DMIX;C:\Program Files\Indri\Indri 5.7\bin;C:\Program Files\Java\jdk1.8.0_11\bin;.
Exception in thread "main" java.lang.UnsatisfiedLinkError: C:\Program Files\Indri\Indri 5.7\bin\indri_jni.dll: Can't find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1929)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1847)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at lemurproject.indri.indriJNI.<clinit>(indriJNI.java:109)
at lemurproject.indri.IndexEnvironment.<init>(IndexEnvironment.java:39)
at indritest.main(indritest.java:10)发布于 2014-08-05 18:53:37
除了项目中的Java类之外,您还使用了一个本机库,即没有用Java编写的库。您需要将本机库添加到类路径中,并且可能需要在使用任何类(如IndexEnvironment )之前通过调用
System.loadLibrary("<NAME OF THE LIBRARY>");从堆栈跟踪中,我猜库名为"indri_jni",因此我认为在Windows上,您应该在Windows中添加"indri_jni.dll“。这通常包括应用程序的工作目录,因此您可能必须将库放在那里,或者将库所在的目录添加到path环境变量中。
https://stackoverflow.com/questions/25146045
复制相似问题