You are here

Java program to get IP address

Java program to print the IP (Internet Protocol) address of a computer system, we use InetAddress class of package, the getLocalHost method returns InetAddress object, which represents the localhost.

Java IP address program


class IPAddress
  public static void main(String args[]) throws Exception

Download IP address program class file.

Output of program:
IP address

The output shows the computer name/ IP address of the computer. Java has a very vast Networking API, which can be used to develop network applications.