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
I am using the line:
The NetworkInterface class contains all the relevant methods, but be aware that there's no such thing as "my IP". A machine can have multiple interfaces and each interface can have multiple IPs.
You can list them all with this class but which interface and IP you choose from the list depends on what you exactly need to use this IP for.
(InetAddress.getLocalHost()
doesn't consult your interfaces, it simply returns constant 127.0.0.1 (for IPv4))