javausb4java

Caused by: org.usb4java.LoaderException: Native library not found in classpath /org/usb4java/windows-x86_64/libusb-1.0.dll


System:

Problem:

Trying to use usb4java package in my project to select correct usb port and start moving information through it. I downloaded the package from usb4java.org, unzipped and added it to the references from java build path.

import org.usb4java.Context;
import org.usb4java.LibUsb;
import org.usb4java.LibUsbException;

 private void initializeLibUsb() {
    int result = LibUsb.init(null);
    if( result != LibUsb.SUCCESS) {
        throw new LibUsbException("Unable to initialize libusb.",result);
    }
}

This results in the error:

Caused by: org.usb4java.LoaderException: Native library not found in classpath: /org/usb4java/windows-x86_64/libusb-1.0.dll

Where am I supposed to get the libusb-1.0.dll?


Solution

  • Included the file lib/libusb-1.0-windows-x86_64.jar in the classpath.