Access USB with Java, in order to find thumbdrive manufacturer's serial#/unique-ID

半世苍凉 提交于 2020-01-10 19:31:25

问题


Looking for a way to read the unique ID / serial# of a USB thumb drive; please note that
- I am looking for the value of the manufacturer, not the one Windows allocates for it.
- I need to support multiple OS (Windows, Unix, Mac), thus needs to be a Java solution

The idea is to be able to distinguish between different USB thumb drives.


回答1:


RXTX is the way to go. In the world of model trains, JMRI (Java Model Railroad Interface) has become very popular. JMRI runs on all platforms (Windows, Linux and Mac) and communicates with a variety of USB based devices (command stations). RXTX is in fact used by JMRI.




回答2:


You might give a look at the following projects: javax-usb and jusb. They seem to support Linux and Windows.

Anyway, since USB access in Java requires the use of native libraries, you might not achieve the required portability.




回答3:


I've never tried using it (it's been on my todo list for a good few months now), but there is the "marge" project on java.net:

http://marge.java.net/

This should let you connect to bluetooth devices (although I don't think it is 100% feature complete, there is demo code on there), and then the ClientDevice class has a "getBluetoothAddress" method which I believe should be unique to that device

http://marge.java.net/javadoc/v06/marge-core/net/java/dev/marge/entity/ClientDevice.html

As I say though, I've never tried it...




回答4:


I have never investigated this thoroughly, but from memory the RXTX library implementation of the javax.comm packages are supposedly very good and now have USB support.



来源:https://stackoverflow.com/questions/73288/access-usb-with-java-in-order-to-find-thumbdrive-manufacturers-serial-unique

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!