In a paper about the Life Science Identifiers (see LSID Tester, a tool for testing Life Science Identifier resolution services), Dr Roderic DM Page wrote :
Given the LSID urn:lsid**:ubio.org**:namebank:11815, querying the DNS for the SRV record for _lsid._tcp.ubio.org returns animalia.ubio.org:80 as the location of the ubio.org LSID service.
I learned that I can link _lsid._tcp.ubio.org to animalia.ubio.org:80 using the host command on unix:
host -t srv _lsid._tcp.ubio.org
_lsid._tcp.ubio.org has SRV record 1 0 80 ANIMALIA.ubio.org
How can I do this 'DNS' thing using the Java J2SE API (Without any external java library, I'd like a lightweight solution ) ?
Thank you
You can't do this using the standard Java libraries. The
InetAddress
class is only capable of looking up DNSA
records.To look up
SRV
records (and indeed any other DNS resource record type other than anA
record) you need a third party library.dnsjava
is the usual option.I've personally used the 1.6 version on Google Android, it works fine. Version 2.0 and later use the Java
nio
layer, so won't be compatible with earlier JVMs.I think you can't do it without using some external libraries. java.util.InetAddress has some methods to resolve names via DNS, but it's only usable for resolving names into IP addresses and not for generic DNS querying.
For that, you need some external library like DNSJava.
The JNDI DNS provider can lookup SRV records. You need to do something like:
The returned attributes are an enumeration of strings that look like "1 0 80 ANIMALIA.ubio.org". The space separated fields are in order:
In case anybody is looking for non-Java solutions (which they might given that the title of the question isn't language specific), when I implemented a LSID (see doi:10.1186/1751-0473-3-2) I used the PEAR package Net_DNS, which can look up SRV records.