Questions tagged «opensolaris»

9
InetAddress.getLocalHost()引发UnknownHostException
我正在不同的操作系统上测试我们的服务器应用程序(用Java编写),并认为由于Java集成良好,OpenSolaris(2008.11)的麻烦最少。原来我错了,因为我最终遇到UnknownHostException try { computerName = InetAddress.getLocalHost().getHostName(); if (computerName.indexOf(".") > -1) computerName = computerName.substring(0, computerName.indexOf(".")).toUpperCase(); } catch (UnknownHostException e) { e.printStackTrace(); } 输出为: java.net.UnknownHostException: desvearth01: desvearth01 at java.net.InetAddress.getLocalHost(InetAddress.java:1353) 但是,nslookup desvearth01返回正确的IP地址,并按预期方式nslookup localhost返回127.0.0.1。同样,相同的代码在FreeBSD上也可以完美地工作。我不知道OpenSolaris有什么特别的地方吗? 任何提示表示赞赏,谢谢。
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.