Showing results for 
Search instead for 
Did you mean: 

JNI Dependencies and cross-platform build

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.


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);
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.



Level 2

Turns out it was a problem of path

KBS Training