JNI依赖关系和跨平台构建

时间:2015-10-14 19:22:33

标签: java maven jenkins java-native-interface usb4java

我目前正在为一个项目工作,我需要检测Oculus设备是否已堵塞。

我使用usb4java库usb4java。

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

我想使用安装在ubuntu服务器上的Maven和Jenkins构建我的程序,但是我遇到了这个库的问题:如果我的程序是使用这台机器构建的,我的功能不起作用,但如果我在Windows上编译它,我的功能就像一个魅力。

这是我使用的功能:

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) {}
        }
    }

我没有得到任何错误,但是使用linux构建的版本检测不起作用(res总是假的)。

我查了一下,包括Windows在内的所有JNI库都在JAR-With-Dependencies中运行。

感谢您的帮助, 卢卡斯

1 个答案:

答案 0 :(得分:0)

原来这是路径问题