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