title: Recommended way to get hostname in Java
body: <p>Which of the following is the best and most portable way to get the hostname of the current computer in Java?</p>
  
  <p><code>Runtime.getRuntime().exec("hostname")</code> </p>
  
  <p>vs </p>
  
  <p><code>InetAddress.getLocalHost().getHostName()</code></p>