title: Java getting my IP address
body: <p>I am trying to get my Internet IP address in Java but I keep getting my local address (ie: 127.0.0.1), when my IP address is 192.168.0.xxx</p>
  
  <p>I am using the line:</p>
  
  <pre><code>InetAddress.getLocalHost().getHostAddress();
  </code></pre>
  
  <p>which seems standard to get the IP address, but it is not what I am looking for. Every tutorial says to use this line, so I am a little confused.</p>
  
  <p>Could anyone please let me know how I can get my correct IP address please?</p>
  
  <hr>
  
  <p>I'm running on a device that is connected to WiFi, and I'm not using any cable. I am connecting to a server using the IP given by ifconfig inet addr, and I am looking to get the device's inet addr.  I could check the IP of the socket on the server side, but thought it'd be nicer if the device (client) tells the server which IP he is expecting other devices to connect on. </p>