Fork me on GitHub

Frequently asked questions

If you have a question which is not answered here please ask the usb4java mailing list (Google group). You can subscribe to it via email by sending a mail to usb4java+subscribe@googlegroups.com.

I can't open my USB device on Linux. Why?

On Linux you need write permissions on the device file of the USB device you want to communicate with. Check if the devices are accessible when running your program as root. If this works then it is recommended to configure udev to give your user write permissions when the device is attached. You can do this by creating a file like /etc/udev/rules.d/99-userusbdevices.rules with content like this:

  SUBSYSTEM=="usb",ATTR{idVendor}=="89ab",ATTR{idProduct}=="4567",MODE="0660",GROUP="wheel"

This means that whenever a USB device with vendor id 0x89ab and product id 0x4567 is attached then the group wheel is permitted to write to the device. So make sure your user is in that group (or use a different group).

If your device uses a shared vendor/product id then you might want to filter for the manufacturer and product name. This can be done by checking the ATTR properties manufacturer and product.

To activate this new configuration you may need to re-attach the USB device or run the command udevadm trigger.

I can't open my USB device on Windows. Why?

On Windows you need to create a driver for your USB device. Read the How to use libusb on Windows article from the libusb project for more information.

My program crashes. What can I do?

If the program crashes with a Java stack trace then it is most likely a problem in your own program. If you can't find it you may find some help on the mailinglist.

If the JVM crashes the hard way because of a segfault in the native code then it is more likely a problem of usb4java or libusb and you should file a bugreport with as much information as possible (Full stack trace, full crash log, example code how to reproduce the crash).

If usb4java crashes on Windows then please first of all make sure you have created a proper device driver as explained in the previous FAQ entry. Also consider creating a new up-to-date device driver with the latest Zadig tool.

If you have experience in C programming then it would be very helpful when you could try to reproduce the problem in C by directly using libusb. If this works but the same USB communication doesn't work with usb4java then it would be nice if you could give us your C source and Java source so we can track down the difference which causes the crash. If the C program also crashes then your problem is located in libusb and not in usb4java and you should consult the libusb mailinglist or bug tracker instead. Never report a problem in the libusb bug tracker or the libusb mailing list if you can't reproduce the problem with a native C program!