Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Calling 'dig' program in a java program

 
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
 
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
 
There will be plenty of time to discuss your objections when and if you return. The cargo is this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic