Fork me on GitHub

Configuration

The configuration options explained here are only valid for the javax-usb extension of usb4java. If you access your USB devices with the native libusb API then no configuration is needed.

Selecting usb4java as javax-usb implementation

To tell the USB Host Manager of javax-usb to use the usb4java implementation you have to put the following property into the javax.usb.properties file which must be located in the root of your classpath:

javax.usb.services = org.usb4java.javax.Services

usb4java can be configured by adding more properties to this file as described in the following sections.

Communication timeout

The default USB communication timeout of usb4java is 2500 milliseconds. To change this to 250 milliseconds for example add this to the properties file:

org.usb4java.javax.timeout = 250

Scan interval

The default USB device scan interval of usb4java is 500 milliseconds. To change this to 1000 milliseconds for example add this to the properties file:

org.usb4java.javax.scanInterval = 1000

When you set this interval to 0 then usb4java only scans once during application startup. If you want to trigger a manual device scan you can do it by calling the scan method on the USB services class (Must be casted to the usb4java implementation, because this is not a javax-usb feature:

((org.usb4java.javax.Services) UsbHostManager.getUsbServices()).scan();

Use USBDK

If you want to use USBDK on Windows then you have to enable the feature with the following entry:

org.usb4java.javax.useUSBDK = true

This setting is ignored on other platforms.