Here you can find the source of getLocalIPAddress()
public static String getLocalIPAddress()
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.UnknownHostException; public class Main { public static String getLocalIPAddress() { return checkIP(getIPFromAPI()); }/*from ww w .ja va2 s . c o m*/ private static String checkIP(String IPAddress) { if (IPAddress == null || IPAddress.equals("127.0.0.1")) { return "<unknown>"; } return IPAddress; } private static String getIPFromAPI() { try { InetAddress IP = InetAddress.getLocalHost(); return IP.getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return null; } } }