Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes nslookup Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "nslookup" Watch "nslookup" New topic
Author

nslookup

Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Does anyone know please how to call an nslookup from within java to test if a domain name exists?
many thanks
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
how about,

regards
maulin
Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Thanks Maulin,
I had heard that it is best to avoid using runtime exec, is this right? Would there be a way to do a nslookup internally from within java?
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi Peter,
well, if v use Runtime.exec() in a manner that is hazardous then YES. it is not recommended. by hazardous i would mean,
if we use absolute paths which are system dependent (like the one i use in the first commented invocation of the exec() having /usr/sbin/nslookup.
in this case it is no longer system independent as it will only work on Unix/Linux where we have nslookup on /usr/sbin/ (well thats the case most of the time though)...
otherwise i really don see a whole lot of problems w/ it in comparision of efforts we will have to put in implementing RFC1739
u can probably find impl in java by googling on "nslookup in java" or something....
anybody else has more views on this?
regards
maulin
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24183
    
  34

I believe the class java.net.InetAddress is what you're looking for. Depending on what you want to do, you can construct one using a dotted-quartet address and then ask the InetAddress for the host name, or vice versa.


[Jess in Action][AskingGoodQuestions]
Peter Straw
Ranch Hand

Joined: Jan 08, 2002
Posts: 79
Thankyou both, that's what was needed
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
thanks "Ernest Friedman-Hill"!
i liked ur idea.
regards
maulin
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: nslookup
 
Similar Threads
Getting the Client machine name
How to Ping in Java???
How To Open a Port in SunSolaris.
getHostName question
Is it poosible to know what is the url of this Cruise Control web app ?