Follows These Steps:
Step-1.Install JDK Version 1.5 to 1.7 in Your System.
Step-2.Open the Notepad Then Write This Code.
import java.net.*;
class IPDemo
{
public static void main(String args[])
{
try
{
InetAddress ip1=InetAddress.getLocalHost();
System.out.println(ip1);
String s1=ip1.getHostName();
System.out.println(s1);
InetAddress ip2=InetAddress.getByName("www.facebook.com");
System.out.println(ip2);
String s2=ip2.getHostAddress();
System.out.println(s2);
}catch(Exception e){}
}
}
Step-3.Save This Code Extention ".java"
Step-4.Open CMD and Then Compile The Code.
e.g - Type on CMD javac then space then name of the program .java then press Enter.
Step-5.Then Run The program.
e.g - Type on CMD java then IPDemo then press Enter.
NOTE:- You can change The Name in Place of www.facebook.com .
I Hope Enjoy To You.
Step-1.Install JDK Version 1.5 to 1.7 in Your System.
Step-2.Open the Notepad Then Write This Code.
import java.net.*;
class IPDemo
{
public static void main(String args[])
{
try
{
InetAddress ip1=InetAddress.getLocalHost();
System.out.println(ip1);
String s1=ip1.getHostName();
System.out.println(s1);
InetAddress ip2=InetAddress.getByName("www.facebook.com");
System.out.println(ip2);
String s2=ip2.getHostAddress();
System.out.println(s2);
}catch(Exception e){}
}
}
Step-3.Save This Code Extention ".java"
Step-4.Open CMD and Then Compile The Code.
e.g - Type on CMD javac then space then name of the program .java then press Enter.
Step-5.Then Run The program.
e.g - Type on CMD java then IPDemo then press Enter.
NOTE:- You can change The Name in Place of www.facebook.com .
I Hope Enjoy To You.
Comments
Post a Comment