I need to know the name of the current computer.
The simplest method is by running:
java.net.InetAddress.getLocalHost().getHostName()
With OpenJDK 7 in a Linux machine, the result is correct, as reported by the system command hostname
.
But with OpenJDK 8, the returned name is localhost
, which is useless.
Why the different behavior? How can I get the real name with Java 8?
Related questions: