• Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling 'dig' program in a java program  RSS feed

 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out how to execute 'dig something TXT' command in java without using JNI. Basically, I'd like to dig some record with type of TXT. Is there an existing Java API for such purpose?
Thanks
 
Vikas Varma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct me if I am wrong.
You want to run the dig program in Linux platform without using JNI.
Use the Runtime.exec() method. For a working example tryout this link
runtime.exec
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,
Yes. I want to simulate 'dig' in Java on Linux. However, I always hesitate to use Runtime.exec, because it is very platform dependent and you have to 'hardcode' the real command. It is this 'real command line' stuff I'd like to avoid. I know you could use java.net.InetAddress to simulate nslookup as
InetAddress ia = InetAddress.getByName("domain.com");
System.out.println(ia.getHostAddress());
System.out.println(ia.getHostName());
Since it is the TXT record type that I need to dig not domain. I am wondering how to achieve 'dig @host something TXT' without JNI and Runtime.exec()...
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey,
Yes. I want to simulate 'dig' in Java on Linux. However, I always hesitate to use Runtime.exec, because it is very platform dependent and you have to 'hardcode' the real command. It is this 'real command line' stuff I'd like to avoid. I know you could use java.net.InetAddress to simulate nslookup as
InetAddress ia = InetAddress.getByName("domain.com");
System.out.println(ia.getHostAddress());
System.out.println(ia.getHostName());
Since it is the TXT record type that I need to dig not domain. I am wondering how to achieve 'dig @host something TXT' without JNI and Runtime.exec()...
 
Vikas Varma
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Then check out this link.
dnsjava
Regards,
--Vikas
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! That is exactly what I am looking for! - Thanks a bunch!
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great! That is exactly what I am looking for! - Thanks a bunch!
 
Elinor Chang
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Vikas:
I just downloaded dnsjava-3.3.1. I am trying to use it for one of my project, where I'll trying to spring hundreds of DNS queries per second. The project is developed in Java.
Because I have to achieve certain performance goal, I'll have to make my program handle about 250 DNS query second. I am kind of wondering if I should use the Lookup object to do so or follow one of the example command line program 'dig.java'? The Lookup object looks rather simple and it even cache request. It might be boost on performance.
Can you provide me suggesion on this?
Thanks
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!