File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

nslookup

 
Peter Straw
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
how about,

regards
maulin
 
Peter Straw
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Straw
Ranch Hand
Posts: 79
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thankyou both, that's what was needed
 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks "Ernest Friedman-Hill"!
i liked ur idea.
regards
maulin
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic