Java Program to Get the IP address

Write a Java program to get the IP address with an example. In this programming language, InetAddress class has all the necessary Internet Protocol (IP) address information. So, we used the getLocalHost method to get the localhost address and the getHostAddress method.

package NumPrograms;


public class IpAddress1 {

	public static void main(String[] args) throws Exception {
		InetAddress myIpAdd = InetAddress.getLocalHost();
		System.out.println("My IP Address is");

IP address