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 most 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 ipconfig
into the command prompt:
Here is the method that will grab the IP address:
import java.net.InetAddress;
import java.net.UnknownHostException;
...
private String getIP() {
try {
return InetAddress.getLocalHost().getHostAddress();
} catch (UnknownHostException e) {
return "0.0.0.0";
}
}
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.
Thank you for your time.