1

I am creating an java application that is for to get list of attached Usb devices and when i run this i get an error called Properties file javax.usb.properties not found.please fix this this is my java code:

package com.example.sample;
import java.util.Iterator;
import java.util.List;    
import javax.usb.*;   
public class Usb
{
    public static void main(String[] args) throws UsbException
    {
            UsbServices services = UsbHostManager.getUsbServices();
            UsbHub root = services.getRootUsbHub();
            listPeripherique(root); 
    }

    private static void listPeripherique(UsbHub hub) {
        List perepheriques = hub.getAttachedUsbDevices();
        Iterator iterator = perepheriques.iterator();
        while (iterator.hasNext()) {
          UsbDevice perepherique = (UsbDevice) iterator.next();
          System.out.println(perepherique);
          if (perepherique.isUsbHub()) {
            listPeripherique((UsbHub) perepherique);
          }
        }           
    }    
}
HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
lakshman
  • 181
  • 8
  • 20

2 Answers2

2

Have you created the javax.usb.properties file ? If not you need to create it, you put it in the folder with all your others files. With inside this file:

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

Have a look to this tutorial: http://usb4java.org/quickstart/javax-usb.html

HaveNoDisplayName
  • 8,291
  • 106
  • 37
  • 47
2

Create resource folder

  • Right click on Java Resources > New > Source Folder
  • At Project name, click Browse button > choose your project name
  • At Folder name, enter your folder name as resource > click on Finish button

Create javax.usb.properties

  • Right click on resource folder > New > Other > File> click Next button
  • Enter File name as javax.usb.properties
  • Click on javax.usb.properties to open > write this :

If using usb4java lib

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