Пытаюсь разобраться с примером приведённым здесь Скачал отсюда библиотеку usb4java
import org.usb4java.Context;
import org.usb4java.Device;
import org.usb4java.DeviceDescriptor;
import org.usb4java.DeviceList;
import org.usb4java.LibUsb;
import org.usb4java.LibUsbException;
public class Main {
public static int vid = 402;
public static int pid = 5661;
public static void main(String[] args) throws ExceptionInInitializerError {
Context context = new Context();
int result = LibUsb.init(context);
if (result != LibUsb.SUCCESS) {
throw new LibUsbException("Unable to initialize the usb device", result);
}
DeviceList list = new DeviceList();
result = LibUsb.getDeviceList(null, list);
if (result < 0) throw new LibUsbException("Unable to get device list", result);
try {
for (Device device : list) {
DeviceDescriptor device_descriptor = new DeviceDescriptor();
result = LibUsb.getDeviceDescriptor(device, device_descriptor);
if (result != LibUsb.SUCCESS) throw new LibUsbException("Unable to get device descriptor : ", result);
System.out.println("Product id is : " + device_descriptor.idProduct() + " " + "Vendor id is : " + device_descriptor.idVendor());
if (device_descriptor.idProduct() == pid && device_descriptor.idVendor() == vid) {
System.out.println("Product id and vendor id was matched");
} else {
System.out.println("Product id and vendor id was not matched");
}
}
} finally {
LibUsb.freeDeviceList(list, true);
}
}
}
На строке int result = LibUsb.init(context); выдаёт ошибку, Как её можно устранить?
Exception in thread "main" java.lang.ExceptionInInitializerError at prog.Main.main(Main.java:15) 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 com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) Caused by: org.usb4java.LoaderException: Native library not found in classpath: /org/usb4java/windows-x86_64/libusb-1.0.dll at org.usb4java.Loader.extractLibrary(Loader.java:281) at org.usb4java.Loader.load(Loader.java:356) at org.usb4java.LibUsb.(LibUsb.java:640) ... 6 more