• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to find a ip address from any host...

 
vikas de
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi friends,
did somebody know how to find the ipaddress of any machine on the net.
please see the code...
import java.net.*;
class ip
{
public static void main(String args[])
{
try
{
InetAddress io[]=InetAddress.getByName("www.yahoo.com");
System.out.println(io);
}
catch(Exception e)
{
System.out.println("host not found....");
}
}
}
thanx a lot guys...
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try this:

------------------
Moderator of the JDBC Forum
[This message has been edited by Thomas Paul (edited February 21, 2001).]
[This message has been edited by Thomas Paul (edited February 21, 2001).]
 
vikas de
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi guys,
I tried this programm but all it displays is(i am connected to the Internet)
host not found...
please Help as soon as possible its urgent...
thanx a lot..
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why don't you display the exception instead of just printing out the error message?
change the catch to:
System.out.println(e.getMessage());
e.printStackTrace();
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!