0

followed the instruction as stated here . Added the properties file in my root project and libraries on the project class path. When i run the project, it returns.

Exception in thread "main" javax.usb.UsbPlatformException: Class org.usb4java.javax.Services does not have the needed constructor
at javax.usb.UsbHostManager.initialize(UsbHostManager.java:46)
at javax.usb.UsbHostManager.getUsbServices(UsbHostManager.java:24)
at usbfinderdemo.UsbFinderDemo.main(UsbFinderDemo.java:30)

Don't know what might be wrong. Thinking i might not be using the right .jar file of usb4java, but i'm not certain yet as the code does not show any error at all.

Code Snippet

UsbServices services = UsbHostManager.getUsbServices();//the line that throws the error.
    UsbHub rootHub = services.getRootUsbHub();

    List<UsbDevice> devices = rootHub.getAttachedUsbDevices();
    if (devices.size() > 0) {
        System.out.println("USB devices found.");
    } else {
        System.out.println("No USB devices found.");
    }

    for (UsbDevice device : devices) {
        System.out.println("\tProduct String " + device.getProductString());
        System.out.println("\tManufacturer String " + device.getManufacturerString());
        System.out.println("\tSerial Number " + device.getSerialNumberString());
    }
Belvi Nosakhare
  • 3,107
  • 5
  • 32
  • 65

0 Answers0