Get IP Address In Java Example
Chapter:
Networking
Last Updated:
07-04-2016 18:33:20 UTC
Program:
/* ............... START ............... */
import java.net.InetAddress;
public class JavaIPAddress {
public static void main(String args[]) throws Exception {
System.out.println(InetAddress.getLocalHost());
}
}
/* ............... END ............... */
Output
JavaScan-PC/192.168.1.118
Notes:
-
In Java InetAddress.getLocalHost() should give you the IP address of the host.
Tags
Get IP Address, Java