B4J Question Windows BLE Library Help

walterf25

Expert
Licensed User
Longtime User
Hi all, i have the need to create a small program to connect to a BLE device using Windows, I came across this library https://github.com/tongo/ble-java here and am currently trying to create a small wrapper to test and see if it works, so far the library compiles, i am using eclipse to wrap the library, when I try running it in B4J i get the following Error:
Waiting for debugger to connect...
Program started.
java.lang.UnsatisfiedLinkError: no unix-java in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at cx.ath.matthew.unix.UnixSocket.<clinit>(UnixSocket.java:33)
at org.freedesktop.dbus.Transport.connect(Transport.java:772)
at org.freedesktop.dbus.Transport.<init>(Transport.java:737)
at org.freedesktop.dbus.DBusConnection.<init>(DBusConnection.java:299)
at org.freedesktop.dbus.DBusConnection.getConnection(DBusConnection.java:282)
at it.tangodev.ble.BleApplication.start(BleApplication.java:76)
at com.genesis.ble.JBLE.Initialize(JBLE.java:91)
at com.genesis.bletest.main$ResumableSub_AppStart.resume(main.java:126)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
java.lang.RuntimeException: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no unix-java in java.library.path
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1020)
at com.sun.javafx.application.PlatformImpl.lambda$null$172(PlatformImpl.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$173(PlatformImpl.java:294)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$147(WinApplication.java:177)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: no unix-java in java.library.path
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
at anywheresoftware.b4a.shell.ShellBA.raiseEvent2(ShellBA.java:98)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resume(DebugResumableSub.java:42)
at anywheresoftware.b4a.keywords.Common$2$1.run(Common.java:1018)
... 7 more
Caused by: java.lang.UnsatisfiedLinkError: no unix-java in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at cx.ath.matthew.unix.UnixSocket.<clinit>(UnixSocket.java:33)
at org.freedesktop.dbus.Transport.connect(Transport.java:772)
at org.freedesktop.dbus.Transport.<init>(Transport.java:737)
at org.freedesktop.dbus.DBusConnection.<init>(DBusConnection.java:299)
at org.freedesktop.dbus.DBusConnection.getConnection(DBusConnection.java:282)
at it.tangodev.ble.BleApplication.start(BleApplication.java:76)
at com.genesis.ble.JBLE.Initialize(JBLE.java:91)
at com.genesis.bletest.main$ResumableSub_AppStart.resume(main.java:126)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:47)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:632)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:237)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:167)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
... 11 more

I know this error is due to the fact that it can't find the unix library, in the example project they provide in the link above I see the libraries needed in the /libs folder are unix.jar, dbus-java-2.7.jar and libmatthew-java-0.8.jar, normally when I have wrapped libraries the library extensions are .so, this the first time I see a in a project the libraries being used are in .jar extension.

Anyhow, I have placed all those 3 files inside the /lib folder in my eclipse project, and I have even tried using the System.LoadLibrary() method but even so i still get some other errors like, it can't find the library and another error saying that the library is not a 32bit library.

Any ideas on how I can resolve this issue, Where should I copy this library files to so that the wrapper can load them during run time?

Walter
 

walterf25

Expert
Licensed User
Longtime User
Upvote 0

walterf25

Expert
Licensed User
Longtime User
As described here for eg., you need to include unix-java.so jni lib:
Yeah I saw that, going back to the github project it seems this will only work in Linux.

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
But looking your log, I think you need to have this Library
You may be right, either way even if i am able to find this library, it won't work on a Windows machine which is the whole purpose of me wrapping this library.

Walter
 
Upvote 0

walterf25

Expert
Licensed User
Longtime User
Sorry, I misunderstood it. Need to look further then...
But may be, BLE-JAVA is for linux and we need to port that lib to windows not only wrap it.
Can't we use another project already working in windows like https://github.com/sputnikdev/bluetooth-manager ?
I already looked at this project, but it seems this only works for those specific usb-adapters/dongles, This is a project I need to do at work and it will be used by many Engineers, so the option of having to buy and insert an additional usb-BLE adapter is not very optimal.

Thanks for the suggestion though, I am a bit bothererd at the fact that there's nothing already ported that can work with windows.

Walter
 
Upvote 0
Top