tongo/ble-java

java.lang.UnsatisfiedLinkError: no unix-java in java.library.path

Closed this issue · 4 comments

As mentioned we installed libdbus-java on pi
command
sudo apt-get install libdbus-java

BLUEZ version 5.47 installed

Compiled the source but when we execute we get below error

java.lang.UnsatisfiedLinkError: no unix-java in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1864)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at cx.ath.matthew.unix.UnixSocket.(UnixSocket.java:40)
at org.freedesktop.dbus.Transport.connect(Transport.java:772)
at org.freedesktop.dbus.Transport.(Transport.java:737)
at org.freedesktop.dbus.DBusConnection.(DBusConnection.java:299)
at org.freedesktop.dbus.DBusConnection.getConnection(DBusConnection.java:282)
at it.tangodev.ble.BleApplication.start(BleApplication.java:76)
at example.ExampleMain.(ExampleMain.java:69)
at example.ExampleMain.main(ExampleMain.java:86)

Are we missing something here?

tongo commented

Hi, you also need the unix.jar library.
You can find it in the libs folder:
https://github.com/tongo/ble-java/tree/master/libs

You also need the other library in that folder, include it in your project.
Let me know if you resolve.

I added all the 3 libraries present in link https://github.com/tongo/ble-java/tree/master/libs
in the library and also executable jar project of raspberry pi, still getting the same error as mentioned before.

image

I tried adding linunix-java.so to the lib folder of executable jar project.
Also tried to explicitly set the library path.

image

Please suggest me if I am missing something.

tongo commented

Try to add "-Djava.library.path=/usr/lib/jni" parameter to your jar call:
sudo java -jar -Djava.library.path=/usr/lib/jni /home/pi/YOUR_JAR

This tell java where is unix-java library installed

Thanks. It worked.