9

It works okay for me but on OSX Mavericks for a particular customer InetAddress.getLocalHost() is failing with Java 7 although it works okay with Java 6 with the following exception

java.net.UnknownHostException: rupert: rupert: nodename nor servname provided, or not known
    at java.net.InetAddress.getLocalHost(InetAddress.java:1466)
Caused by: java.net.UnknownHostException: rupert: nodename nor servname provided, or not known
    at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
    at java.net.InetAddress$1.lookupAllHostAddr(InetAddress.java:894)
    at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1286)
    at java.net.InetAddress.getLocalHost(InetAddress.java:1462)

Is this by design ?

Update

Looks to be a known bug fixed in Java 8

https://bugs.openjdk.java.net/browse/JDK-7180557

4

2 回答 2

7

将其中的 {yourhostname} 部分添加到/etc/hosts

例如

127.0.0.1       localhost {yourhostname}

问题就消失了。

于 2015-09-17T10:42:16.003 回答
4

我猜你会在这里找到答案——尽管这个问题是关于 Solaris 的,但 Mac OS X 和 Solaris 都是 Unix 操作系统。

于 2013-11-08T20:35:24.200 回答