-
DNS through java
I am behind a proxy and want to find the IP no. of an Internet addresses.
I wrote the following :
public class DNS
{ public static void main(String args[])
{ System.getProperties().put( "proxySet", "true" );
System.getProperties().put( "proxyHost", "proxy compu." );
System.getProperties().put( "proxyPort", port );
try
{ InetAddress add=InetAddress.getLocalHost();
String name="www.yahoo.com";
InetAddress newad=InetAddress.getByName(name);
System.err.println("IP no. of "+name+" is : "+newad);
}
catch(Exception e)
{ e.printStackTrace(); }
}
}
This is giving :
java.net.UnknownHostException: www.yahoo.com
This was somewhat expected. But is there a way by which I can use a DNS server
in my network directly through the prog. and get my reply ? I know the IP no.
of the DNS server.
Regards. Samik.
Please Email a copy of reply to [email protected]
-
Re: DNS through java
There is a package available through the CodeGuru web site that will do DNS functions for you. I assume that it will work for your purposes. I have not tried it myself. Check it out at
http://www.codeguru.com/java/articles/334.shtml