Possible Duplicate:
java InetAddress.getLocalHost(); returns 127.0.0.1 … how to get REAL IP?
I have run the below code in different operation system. When i run this in ubuntu 11.4 I got 127.0.1.1 but the same time i got actual ip 192.XXX.XXX.XXX in windows. How can i get actual ip?
import java.net.*;
import java.io.*;
public class GetIPAddress {
public static void main(String [] args) {
try {
InetAddress thisIp =InetAddress.getLocalHost();
System.out.println("IP:"+thisIp.getHostAddress());
}
catch(Exception e) {
e.printStackTrace();
}
}
}
Cheers..