In the file C:\WINDOWS\system32\drivers\etc\hosts I have only the following line
192.168.0.23 computername.domain.com computername
When I run
InetAddress localhost = InetAddress.getLocalHost();
System.out.println("getLocalHost:" + localhost);
I would expect the output to be
getLocalHost:computername/192.168.0.23
but it comes out as
getLocalHost:computername/192.168.0.107
Any ideas on why this happens? Should the configuration be made in some other file (too)?
EDIT
InetAddress.getByName('computername')
produces the same IP as getLocalHost()
does.