cancel
Showing results for 
Search instead for 
Did you mean: 

JNI Dependencies and cross-platform build

sandeepkumar10
Level 2

Hi all, I'm currently working for a project for which I need to detect whether an Oculus device is plugged or not.

I do so using the usb4java library usb4java.

<dependency>
<groupId>org.usb4java</groupId>
<artifactId>usb4java-javax</artifactId>
<version>1.2.0</version>
</dependency>

I want to build my program using Maven and Jenkins, which are installed on a ubuntu server, but I'm facing a problem with this library: if my program is built using this machine, my function is not working, but if I compile it on windows, my function is working like a charm:smile:

Here is the function I use :

if (hub == null) {
UsbServices services = UsbHostManager.getUsbServices();
hub = services.getRootUsbHub();
}
//List all the USBs attached
List devices = hub.getAttachedUsbDevices();
Iterator iterator = devices.iterator();
boolean res = false;
while (iterator.hasNext()) {
UsbDevice device = (UsbDevice) iterator.next();
UsbDeviceDescriptor desc = device.getUsbDeviceDescriptor();
if (device.isUsbHub()) {
res = res || isOculusPlugged((UsbHub) device);
}
else {
try {
if (desc.idVendor() == 10291) {
res = true;
}
} catch (NullPointerException ignored) {}
}
}

I get not error whatsoever, but the detection is just not working (res is always false) with the linux-built version.

I checked and all JNI libs including Windows is in the JAR-With-Dependencies I'm running.

Thanks.

1 REPLY 1

johnson267
Level 2

Turns out it was a problem of path

KBS Training