- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我使用以下代码获取连接到系统的 USB 设备的制造商代码。我添加了 jsr80-1.0.1 jar 。我收到以下错误 javax.usb.UsbException:
Properties file javax.usb.properties not found.
有什么建议吗?
import java.io.UnsupportedEncodingException;
import java.util.*;
import javax.usb.*;
public class USBListener {
public static void main(String[] args) {
try{
UsbServices services = UsbHostManager.getUsbServices();
UsbHub root = services.getRootUsbHub();
listDevices(root);
} catch (Exception e) {
System.out.println(e);
}
}
public static void listDevices(UsbHub hub) throws UnsupportedEncodingException, UsbException {
List devices = hub.getAttachedUsbDevices();
Iterator iterator = devices.iterator();
while(iterator.hasNext()) {
UsbDevice device = (UsbDevice)iterator.next();
describe(device);
if(device.isUsbHub()) {
System.out.println("is hub");
}
}
}
public static void describe(UsbDevice device)
throws UnsupportedEncodingException, UsbException {
UsbDeviceDescriptor descriptor = device.getUsbDeviceDescriptor();
byte manufacturerCode = descriptor.iManufacturer();
System.out.println("Manufacturer index: " + manufacturerCode);
System.out.println("Manufacturer String: " + device.getString(manufacturerCode));
System.out.println("USB version: " + decodeBCD(descriptor.bcdUSB()));
System.out.println("Maximum control packet size: " + descriptor.bMaxPacketSize0());
}
public static String decodeBCD(short bcd) {
int upper = (0xFF00 & bcd) >> 8;
int middle = (0xF0 & bcd) >> 4;
int lower = 0x0F & bcd;
return upper + "." + middle + "." + lower;
}
}
最佳答案
您的类路径中需要此文件。来自文档:
The javax.usb.properties file is a Java properties file that is required by the API implementation loader class. The properties file must be loadable by normal means (i.e. it must be in the CLASSPATH) and it must contain the property javax.usb.services. This property must be defined. Its value must be the fully qualified class name of a class that implements the interface javax.usb.UsbServices. This class will be loaded as the implementation of javax.usb.
此外,如果您看到此错误,您可能还没有实现 javax.usb:
You need a javax.usb implementation; the file is provided by all javax.usb implementations
参见此处:http://javax-usb.sourceforge.net/faq.html#what_is_properties_file
关于javax.usb.UsbException : Properties file javax. 未找到 usb.properties,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6913399/
我使用以下代码获取连接到系统的 USB 设备的制造商代码。我添加了 jsr80-1.0.1 jar 。我收到以下错误 javax.usb.UsbException: Properties file j
我是一名优秀的程序员,十分优秀!