Reputation: 9478
iam just simply trying to know what are the input devices and output devices connected to the system. Do there any api to get information about input/output devices using java?
EDIT
independent of any operating system.
Please suggest.
Upvotes: 2
Views: 3058
Reputation: 4891
To find what usb devices are connected to the system you can use jUSB. This article has more in-depth information on how to use the api. In particular, to find all usb devices (slightly modified from the article):
Host host = HostFactory.getHost();
// Obtain a list of the USB buses available on the Host.
Bus[] bus = host.getBusses();
// Traverse through all the USB buses.
for (int i = 0; i < bus.length; i++) {
// Access the root hub on the USB bus and obtain the number of USB ports available on the root hub.
Device root = bus[i].getRootHub();
int totalPorts = root.getNumPorts();
// Traverse through all the USB ports available on the
// root hub. It should be mentioned that the numbering
// starts from 1, not 0.
for (int j=1; j<=total_port; j++) {
// Obtain the Device connected to the port.
Device device = root.getChild(j);
if (device != null) {
// USB device available, do something here.
}
}
}
Similarly, you can use the api for MIDI systems to find what MIDI devices are connected, see the java tutorials for more information.
Upvotes: 2
Reputation: 7540
I think you should try commandline via java Runtime.getRuntime().exec(command);
According to this site http://michaelminn.com/linux/command_line Following command should return this:
lspci: Lists information about devices connected to the internal PCI busses.
lspci -vv: Full dump of information.
so
String command="lspci";
And from windows you may need to download DevCon command! http://support.microsoft.com/kb/311272/EN-US
so
String command="devcon find";
Upvotes: 0