2015-02-07 267 views
0

我正在創建一個用於獲取連接的USB設備列表的Java應用程序,當我運行此操作時,出現一個名爲的錯誤屬性文件javax.usb.properties not發現,請您及時解決這個問題 這是我的java代碼:如何修復屬性文件javax.usb.properties not found

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); 
      } 
     }   
    }  
} 
+0

有你閱讀:http://stackoverflow.com/questions/6913399/javax-usb-usbexception-properties-file -javax-usb-properties-not-found? – 2015-02-07 08:50:31

+0

[Java USB library]的可能重複(http://stackoverflow.com/questions/862880/java-usb-library) – 2015-02-07 09:02:04

回答

2

有您所創建的文件javax.usb.properties?如果不是,則需要創建它,然後將其與所有其他文件放在該文件夾中。有了這個文件中:

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

,看一下這個教程:http://usb4java.org/quickstart/javax-usb.html