[an error occurred while processing this directive]

Get System Ip


The System IP address is a unique numerical identification assigned to a different system involved in the network for communication. The Format for a IP address is a 32- bit numeric address written as four number separated by periods i.e is an example of IP address. Two IP address cannot be same as it would rise to IP conflict in a System.

Understand with Example

In this Tutorial we want to describe you a code that helps you in understanding to get a IP address. For this we have a class name GetSystemIP,Inside the main method we have a class NetworkInterface,this class represents a Network Interface made up of a name and a list of IP addresses assigned to this interface. This is used to identify the list of multicast group joined  to identify the local interface.

1)getNetworkInterface( )  -  This method returns you the interface used on this machine.

The System.outprintln print the interface name by calling the get Display Name ( ) method.

2)getDisplayName ( )       -  This method returns you name of the network interface.

3)getInet Addresses( )      - This  method returns you Enumeration with  all the  subset of the Inet addresses bound to this network interface.

4)get Host Name( )           - This method returns you the information about the hostname for the current machine.

5)get Host Address( )        -This method return you the address of the host.

The inet Address class provides you the IP address of the current system.


import java.net.*;
import java.util.*;

public class GetSystemIP {

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

  Enumeration<NetworkInterface> nets = 

    for (NetworkInterface netint : Collections.list(nets)) {
     System.out.println("\nInterface Name : " + netint.getDisplayName());

      Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();

       for (InetAddress inetAddress : Collections.list(inetAddresses)) {

         System.out.println("Local host Name\t: " + inetAddress.getHostName());
         System.out.println("Host Address\t: " + inetAddress.getHostAddress());



Interface name  : MS TCP Loopback interface
Local host name : localhost
Host Address    : /

Display name    : Intel(R) PRO/100 VE Network Connection - 
                  Packet Scheduler Miniport
Local host name : SAM
Host Address    : /

Download code


[an error occurred while processing this directive]