Getting IP Address of Current Machine Using Java Program

Sharing is healthy !!

Today you will learn getting IP address of current machine using java program.

Getting IP Address of Current Machine Using Java Program

Getting IP Address of Current Machine Using Java Program

We all know our machine(Desktop or Laptop) Internet Protocol(IP) address just by opening Control Panel\Network and Internet\Network Connections, then selecting active network connection. In that we have to click on details button to know Internet Protocol(IP) address. The above said method is rather a simple way to know Internet Protocol(IP) address. Today we will learn to write a java program that displays current machine Internet Protocol(IP) address. Let’s get into example,

EXAMPLE: GETTING IP ADDRESS OF CURRENT MACHINE USING JAVA PROGRAM

Also Read – Create File Java Program

import java.net.InetAddress;

public class Display_IP_Address {

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

System.out.println(InetAddress.getLocalHost());

}
}
Sharing is healthy !!