Search code examples
javajava-native-interfaceejdb

ejdb Java binding not working "no jejdb in java.library.path"


I'm trying to get the java binding of ejdb (http://ejdb.org/) to work. The bindings can be found on Github: https://github.com/Softmotions/ejdb-java

The binding can be build via the usual ./configure && make && make install step. The result is a libjejdb.so file in the target directory and a java library.

Running the examples fails:

java -Djava.library.path=/Users/foo/test/lib -jar jejdb-sample1.jar
Exception in thread "main" java.lang.UnsatisfiedLinkError: no jejdb in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at org.ejdb.driver.EJDB.<clinit>(EJDB.java:56)
at org.ejdb.sample1.Main.main(Main.java:19)

I checked the supplied java.library.path and it does contain libjejdb.so.

After that I created a multiple copies named jejdb.som jejdb, and so on, just to be sure:

~/test/lib % file *
jejdb:             Mach-O 64-bit dynamically linked shared library x86_64
jejdb.so:          Mach-O 64-bit dynamically linked shared library x86_64
libjejdb.so:       Mach-O 64-bit dynamically linked shared library x86_64
libjejdb.so.1:     Mach-O 64-bit dynamically linked shared library x86_64
libjejdb.so.1.0.0: Mach-O 64-bit dynamically linked shared library x86_64

I still get the same error...

The library in the code is loaded via

static {
    System.loadLibrary("jejdb");
}

and I would expect that libjejdb.so is the correct filename.

I'm confused that the library is still not found?


Solution

  • It is strange that you where able to build the code in the first place because on my side I needed to change stuff in configure, configure.ac and Makefile.in to be able for this to compile properly on MacOSX

    However, assuming that this is not a real issue, I did the following to get the example to run and assuming that your .so file is installed in ~/test/lib as mentioned above

    # remove un-needed environment variable
    unset LD_LIBRARY_PATH
    # set proper shared library names on MacOSX in 
    for n in libjejdb.dylib libjejdb.1.dylib libjejdb.1.0.0.dylib; do ln -s libjejdb.so ~/test/lib/$n; done
    # Relaunch example using your previous command
    java -Djava.library.path=/Users/foo/test/lib -jar jejdb-sample1.jar
    

    Hope this will solve your issue

    Best regards