Java program to display the IP Address of a particular Host

Program : To display the IP Address of a particular Host
By : Kapil Lohia

import java.net.*;
import java.io.*;
 
public class ip_host
{
	public static void main(String args[]) throws Exception
	{
		System.out.println("Enter the host name :");
		String n=new DataInputStream(System.in).readLine();
 
		InetAddress ipadd =InetAddress.getByName(n);
 
		System.out.println("IP address :"+ipadd);
	}
}

3 Responses to “Java program to display the IP Address of a particular Host”

    • save the program by name ip_host
      then compile on terminal using javac ip_host.java and run using java ip_host

      Reply

Leave a Reply