How to get a fully qualified domain name
InetAddress.getCanonicalHostName() does not return a fully qualified domain name (FQDN) but rather a short host name.
I tried this on a Sun and linux server with Java 1.5.
nsswitch.conf has following entry
hosts: files dns
nslookup for machine "abc" returns its FQDN
$>nslookup abc
Name: abc.company.com
$>cat /etc/hosts | grep abc
x.x.x.x abc abc.company.com abc1
getCanonicalHostName returns only "abc".
When I set the system property sun.net.spi.nameservice.provider.1" to "dns,sun"
getCanonicalHostName returns a FQDN (in this case "abc.company.com")
But being a library vendor, I cannot change this JVM property or configuration files.
Is there a way I can get a FQDN
Thanks you for your help.