I am trying to get the host name off the server where it is running.
Java code:
import java.net.InetAddress;
System.out.println("Host Name: " + InetAddress.getLocalHost().getHostName());
System.exit(0);
Output:
java.net.UnknownHostException: ThinkPad-Edge-E430: ThinkPad-Edge-E430: Name or service not known
at java.net.InetAddress.getLocalHost(InetAddress.java:1473)
at MailQ.main(MailQ.java:45)
Caused by: java.net.UnknownHostException: ThinkPad-Edge-E430: Name or service not known
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:901)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1293)
at java.net.InetAddress.getLocalHost(InetAddress.java:1469)
... 1 more
Hosts:
127.0.0.1 localhost #admin.local.com
#127.0.1.1 ThinkPad-Edge-E430
192.168.81.238 admin.local.com
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
I cant find what is the issue here. Can some help me out?