Aren't there any system calls or OS specific functions that can be called by Java to get just the names of the USB devices attached?
I've seen probably 6-7 questions here only, but everyone mentions the C++ functions GetRawInputDeviceList()
etc, and they are not cross-platform compliant. Either for Windows in C# or C++ or for Linux only.
But I'm working in Java. Also, this needs to be cross platform.
Atleast, it needs to be working for Windows,Linux and Mac. I can work with terminal/shell/command-prompt commands also. I guess I can run them with Java.
I've tried getFileSystemView
and listRoots
. But they give out names of all drives [dvd, hdd partitions,floppy etc].
I need to get only USB devices.
Please don't mention jUSB or JSR080. Why:
jUSB: access to USB devices currently requires that they be connected to a GNU/Linux host system
javax.usb: pre-alpha Windows implementation is not certified and requires a kernel driver.
usb4java: basically, it just implements JSR80 with little more abstraction, perhaps
Although to be honest I haven't tried libusb since it is in C++.
If you are going to mention APIs, mention completely tested and tried ones, that work across Linux,Windows and Mac.
If that wasn't the case, I wouldn't have put this question up. I've seen the mention of jUSB, javax.usb, etc on many other posts.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…