Here you can find the source of getLocalIP()
public static String getLocalIP()
//package com.java2s; //License from project: Apache License import java.net.*; public class Main { public static String getLocalIP() { try {/*from w w w. j a v a2 s . c o m*/ return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); } return null; } }