java.net.InetAddress.getLocalHost().getHostName() is returning localhost instead of the server's hostname in the Java 8
Issue
During the process of migration from JBOSS 6.4 to 7.2, it was verified that when calling java.net.InetAddress.getLocalHost().getHostName()
, it is getting localhost
back instead of the FQDN of the server. If it is set -Djava.net.preferIPv4Stack=false
, it returns the FQDN, but IPv6 addresses are not used, only IPv4. Is there another option to function call returns the FQDN instead of localhost
?
Environment
- Red Hat JBoss Enterprise Application Platform (EAP) 7.x
- Red Hat OpenJDK 8.x
Subscriber exclusive content
A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.