java server ip address code example
Example: How to get server IP address in java
import java.net.InetAddress;
import java.net.UnknownHostException;
public class GetServerIPAddress
{
public static void main(String[] args)
{
InetAddress ia;
try
{
ia = InetAddress.getLocalHost();
System.out.println("get server ip address: " + ia);
}
catch(UnknownHostException ex)
{
ex.printStackTrace();
}
}
}