tongo / ble-java

A Java BLE (bluetooth 4.0) library for bluez.
MIT License
42 stars 19 forks source link

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

Closed ranigupta1295 closed 5 years ago

ranigupta1295 commented 5 years ago

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 5 years ago

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.

ranigupta1295 commented 5 years ago

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 5 years ago

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

ranigupta1295 commented 5 years ago

Thanks. It worked.