Java tutorial
import java.util.Enumeration; import java.util.Hashtable; import javax.naming.directory.Attribute; import javax.naming.directory.Attributes; import javax.naming.directory.DirContext; import javax.naming.directory.InitialDirContext; public class Main { public static void main(String args[]) throws Exception { Hashtable<String, String> env = new Hashtable<String, String>(); env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory"); env.put("java.naming.provider.url", "dns://123.123.123.123/"); String dns_attributes[] = { "MX", "A", "HINFO" }; DirContext ctx = new InitialDirContext(env); Attributes attrsl = ctx.getAttributes("http://www.yourserver.com", dns_attributes); for (int z = 0; z < dns_attributes.length; z++) { Attribute attr = attrsl.get(dns_attributes[z]); if (attr != null) { System.out.print(dns_attributes[z] + ": "); for (Enumeration vals = attr.getAll(); vals.hasMoreElements();) { System.out.println(vals.nextElement()); } } } } }