This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer (Exam 1Z0-830) Java SE 17 Developer (Exam 1Z0-829) Programmer’s Guide and have Khalid Mughal and Vasily Strelnikov on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Calling 'dig' program in a java program

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic