artaxerxe
artaxerxe

Reputation: 6411

How to read all network cards with java

I want to lookup in my system (using java) for all network cards and network interfaces. So, more exactly, I want to get the whole output from ifconfig command (in Linux) but in Java. I know if I use NetworkInterface.getNetworkInterfaces() will return only configured network interfaces.

A rough approach I found at this link. It is OK, but I'm interested if there are other possibilities on this.

Upvotes: 1

Views: 2424

Answers (1)

Sunil Kumar Sahoo
Sunil Kumar Sahoo

Reputation: 53657

You can use Runtime.getRuntime().exec("ipconfig") for Windows and Runtime.getRuntime().exec("ifconfig") for linux to get ifconfig result in java

There is no way to get to the gory details here in 100% Java. You can either execute commands or write JNI.

Upvotes: 2

Related Questions