Results 1 to 1 of 1
- 03-08-2012, 05:38 PM #1
Member
- Join Date
- Mar 2012
- Posts
- 1
- Rep Power
- 0
Need help with InetAddress.getLocalHost.getHostAddress
Hi Gentlemen,
I am working with a customer who has a host that doesn't have DNS configured. While trying to install one of our products, it used to fail at a point, when InetAddress was failing to return hostname and ip address of the localhost with UnknownHostException indication. nslookup won't work.!
The /etc/hosts has proper entries with the localhost defined along with its IP.
I have no clue where the InetAddress looks for to get the Ip and hostname. Any inputs where else it might look.?
The code snippet is as below:
"
import java.net.InetAddress;
public class logInetInfo
{
public static void main(String args[])
{
try {
InetAddress[] iaAll = InetAddress.getAllByName(InetAddress.getLocalHost( ).getHostName());
for (int i = 0; i < iaAll.length; i++) {
System.out.println ("Local Hostname : " + iaAll[i].getHostName().toLowerCase());
System.out.println ("Local IP Address : " + iaAll[i].getHostAddress());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
"
/etc/hosts file looks like this:
127.0.0.1 localhost.localdomain localhost
10.31.150.143 jerry
Any inuts where else i can look at would be very helpful..!
Thanks,
Sriharsha
Similar Threads
-
InetAddress.getByName
By dewitrydan in forum New To JavaReplies: 2Last Post: 11-03-2010, 08:00 AM -
InetAddress.getLocalHost() issue...
By shahdharmit in forum NetworkingReplies: 1Last Post: 10-18-2009, 02:22 AM -
convert InetAddress to a string
By hunterbdb in forum New To JavaReplies: 4Last Post: 10-18-2008, 09:50 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks