专用Linux服务器抛出UnknownHostException。
InetAddress addr;
try {
addr = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
throw new InstantiationError("cannot find hub ip");
}
答案 0 :(得分:3)
您可能没有localhost
{win} /etc/hosts
(linux)中system32\drivers\etc\hosts
的映射
答案 1 :(得分:0)
我找到的另一个选项就是这个(我喜欢,因为我现在不必在两个文件中重复主机名)...
java getLocalHost() UnknownHostException /etc/hosts file differs linux api?