Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting IP address of Interface whose network cable is unplugged

 
Suparn Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
I have a system with three NIC each on different subnet. I am working on a code that wants me to get the ip address of all the interfaces even if no network cable is connected to them. I dont need the IP addresses of the disabled interfaces. Please help me. It kinda urgent!!
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suparn Gupta wrote:It kinda urgent!!

Please EaseUp. There is no such thing as urgent around here.
 
Rob Spoor
Sheriff
Pie
Posts: 20606
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you already check out what you can do with java.net.NetworkInterface?
 
Suparn Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yeah I have checked the java.net package. When I enumerate the network interfaces using getNetworkInferfaces() it doesnt show the nic whose cable is unplugged. Even if I use netsh tool and extract the ip addresses from the output of the command, it wont do my job. I must get a NetworkInterface object for every interface as I have to use it in further code.

Take your time :-)
 
Henry Wong
author
Marshal
Pie
Posts: 21387
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suparn Gupta wrote:Yeah I have checked the java.net package. When I enumerate the network interfaces using getNetworkInferfaces() it doesnt show the nic whose cable is unplugged. Even if I use netsh tool and extract the ip addresses from the output of the command, it wont do my job. I must get a NetworkInterface object for every interface as I have to use it in further code.

Take your time :-)



I believe the java.net package only reports the NICs which are visible via the OS ... meaning if you run "ipconfig" (windows) or "ifconfig" (unix), it should show up. If it doesn't, there is nothing that can be done at the Java layer, it's a operating system or networking issue (you need to talk to your system or network administrator).

Henry
 
Suparn Gupta
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Henry!

I too suspect that. I ll contact my lab admin and see what he has to say.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic