0% found this document useful (0 votes)
7 views

Network Programming - AB 1

This document discusses a Java program that uses the InetAddress class to display the IP address of the system, the program gets the IP address string using the getHostAddress() method and was compiled and run on a Windows system.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Network Programming - AB 1

This document discusses a Java program that uses the InetAddress class to display the IP address of the system, the program gets the IP address string using the getHostAddress() method and was compiled and run on a Windows system.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

LAB 1 - IP ADDRESS

 This is a Java Program to Display the IP Address of the System.


 InetAddress class represents an Internet Protocol (IP) address. We use the
method named getHostAddress() of this class to get the IP address string in
textual presentation.
 Here is the source code of the Java Program to Display the IP Address of the
System. The Java program is successfully compiled and run on a Windows
system. The program output is also shown below.

PROGRAM
import java.net.InetAddress;
public class IP_Address
{
public static void main(String args[]) throws Exception
{
InetAddress IP = InetAddress.getLocalHost();
System.out.println("IP of my system is := "+IP.getHostAddress());
}
}

Output:

IP of my system is := 127.0.1.1

You might also like