title: Obtaining domain name using Java
body: <p>How do I obtain the domain name of the machine I am running on using Java?<br>
  For eg, my machine is a server whose domain name could be <code>ec2-44-555-66-777.compute-1.amazonaws.com</code></p>
  
  <p>I tried <code>InetAddress.getLocalHost().getHostName()</code> but that doesn't give me the name above. That gives me the hostname which looks similar to <code>ip-0A11B222</code></p>