getting all ip address of servlet running machine
Mazhar <[email protected]>
| Newsgroups | gmane.comp.java.sun.servlet |
|---|---|
| Message-ID | <001801c2ff69$d7b55770$7500a8c0@mazhar> |
Hi;
I want to get all IP Addresses bind to System running my servlet application, without using request/response Objects. I try java.net.InetAddress class ( All its methods) its working fine for windows but on Linux machine its just give me a single IP 127.0.0.1 and i am unable to get the IP assigned to eth0.
Is there any other way to get the IP...using jdk1.3
The code i am using currently is
InetAddress inetAddress = InetAddress.getLocalHost();
String localHost=inetAddress.getHostName();
InetAddress iNet[] = InetAddress.getAllByName(Localhost);
int i = 0;
while(iNet[i] != null){
String ipAddress = inet[i].getHostAddress();
System.out.println("IP Address = "+ipAddress);
i++;
}
its work fine for windows machine but on Linux its creating problems;
any idea..........
thanks in Advance...
Mazhar Saeed