Hi,
I have the following code in a utility library and can return the right IP address just fine (e.g. 192.168.10.10), when it is called from an independent Java program, or when it is called from some program running on Tomcat:
InetAddress addr; try { addr = InetAddress.getLocalHost(); } catch (UnknownHostException e) { e.printStackTrace(); return null; } byte[] ipAddr = addr.getAddress(); String ipAddrStr = ""; for (int idx = 0; idx< ipAddr.length; idx++) { if (idx > 0) { ipAddrStr += "."; } ipAddrStr += ipAddr[idx]&0xFF; }