Here you can find the source of getWinLocalIP()
public static String getWinLocalIP()
//package com.java2s; //License from project: Apache License import java.net.*; import java.util.Enumeration; public class Main { public static String getWinLocalIP() { String ip = ""; try {/*from ww w . j a v a 2 s .c o m*/ Enumeration<?> e1 = (Enumeration<?>) NetworkInterface.getNetworkInterfaces(); while (e1.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) e1.nextElement(); Enumeration<?> e2 = ni.getInetAddresses(); while (e2.hasMoreElements()) { InetAddress ia = (InetAddress) e2.nextElement(); ip = ia.getHostAddress(); } } } catch (SocketException e) { e.printStackTrace(); } return ip; } }