0

I am working on lemur tool and i am running with some problem.

when i execute the code , java complains

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)

this is My code

    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();
        }
    }
}

I am using jdk 1.8.0_11 x64bit , windows 7 ultimate x64bit , indri5.7 x64bit , eclipse juno x64bit.

..................................................................................................................................................................... EDIT:-

I worked with the solution given by RALF WAGNER now my console is showing this Bug. after printed the System.getProperty("java.library.path") in my console i am getting this output. indri_jni.dll is already present in system32 folder.

My code.

 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();
        }
    }
}

My console outout.

  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)
dheena
  • 85
  • 3
  • 6
  • 15
  • java -Djava.library.path= "" –jar This might help. – Sid Aug 06 '14 at 07:15
  • Run Dependency Walker on `indri_jni.dll` and see what DLLs it requires that you don't have. See also http://stackoverflow.com/questions/6092200 – Luke Woodward Aug 06 '14 at 19:44
  • Thanks frnds , I got my bug cleared with the help of dependency walker ... Thnk u LUKE WOODWARD and RALF WANGER. – dheena Aug 08 '14 at 16:19

1 Answers1

1

In addition to the Java classes from the project you're using a native library i.e. a library that is not written in Java. You need to add the native library to your class path and may need to load the library before using any classes like IndexEnvironment by calling

System.loadLibrary("<NAME OF THE LIBRARY>");

From the stack trace I'd guess that the library is called "indri_jni", so I think on Windows you should add "indri_jni.dll" to your Windows path. This usually includes the working directory of the application so you may have to put the library there or add the directory where the library is found to your path environment variable.

Ralf Wagner
  • 1,467
  • 11
  • 19
  • 1
    (1) Putting the native library on the classpath does **not** help. On Windows, the native library must be on the `PATH`. Print out `System.getProperty("java.library.path")` to see if you've got the path set up correctly. (2) There's no need to load the library yourself - as you can see from the stacktrace the `IndexEnvironment` class is loading the library itself via the `indriJNI` class. – Luke Woodward Aug 05 '14 at 20:10
  • Luke: (1) You're right, I've changed the description. – Ralf Wagner Aug 06 '14 at 07:11
  • Luke: (2) Right again, it's not actually necessary. But I'd prefer the code to fail early and have the dependency clearly in the code. – Ralf Wagner Aug 06 '14 at 07:14