title: Java getHostAddress() Returning VirtualBox IPv4 Address
body: <p>I am using Java to build a simple method within a class that will grab the LAN IPv4 address of the user's machine. For the <em>most</em> part this works well, with one exception... the IP address I get back is the IPv4 address of my VirtualBox Ethernet adapter, as is proven when I enter <code>ipconfig</code> into the command prompt:</p>
  
  <p><img src="https://i.stack.imgur.com/fH34Z.jpg" alt="enter image description here"></p>
  
  <p>Here is the method that will grab the IP address:</p>
  
  <pre><code>import java.net.InetAddress;
  import java.net.UnknownHostException;
  
  ...
  
  private String getIP() {
    try {
      return InetAddress.getLocalHost().getHostAddress();
    } catch (UnknownHostException e) {
      return "0.0.0.0";
    }
  }
  </code></pre>
  
  <p>Could anyone please show me how to work around this? I would like to avoid assuming that the end-user will not have VirtualBox (or something of the like) installed.</p>
  
  <p>Thank you for your time.</p>