The issue is with InetAddress.getLocalHost()
it throws java.net.UnknownHostException when I used with getHostAddress or getHostName.
The workaround is, edit host files.
Open Terminal and type the line shown below to edit in etc/hosts.
sudo nano /private/etc/hosts
Enter password.
In etc/hosts, (use arrow keys to move around) add a new line with IP address <space> and hostname
Here, you can get the hostname by typing 'hostname' in terminal
To save control+o, then enter and to exit control+x
Now back in terminal, flush the cache by
dscacheutil -flushcache
Now, there should not be any error.
Sometimes you get both hostname and IP with getLocalHost(). Therefore, from getLocalhost() extract only the substring with the IP.
Steps are:
- First convert the inetAddress you get with getLocalHost to String.
- Then get the substring with the IP (Original String will be in the form of <host_name>/<IP>) e.g. String ip_addr
- Convert back the IP substring to inetAddress to be used in Socket. InetAddress.getName(ip_addr)
More information @ http://java.net/jira/browse/MACOSX_PORT-564
My Experience...: Mac Os X - Inetaddress.Getlocalhost() Throws Unknownhostexception >>>>> Download Now
ReplyDelete>>>>> Download Full
My Experience...: Mac Os X - Inetaddress.Getlocalhost() Throws Unknownhostexception >>>>> Download LINK
>>>>> Download Now
My Experience...: Mac Os X - Inetaddress.Getlocalhost() Throws Unknownhostexception >>>>> Download Full
>>>>> Download LINK