iT Portal

How to find my Host Name and IP address ????

Find your Host Information

An IP address is a numerical unique identification number which is assigned to the devices participating in the network for communication. To get IP address of our own system in a java program we will be using InetAddress class.

Java program to find out your Host Name and Ip

import java.util.*;
import java.lang.*;

public class GetHostInfo
public static void main(String args[]) {
try {
InetAddress addr = InetAddress.getLocalHost();
System.out.println(“IP address : =”+addr.getHostAddress());
System.out.println(“Host Name :=”+addr.getHostName());
} catch (UnknownHostException e) {

Output :

IP address : =
Host Name :=Ashok-PC

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: