이 오류는 이전 오류와 관련된 내용으로 InetAddress.getLocalHost()
과 오류가 있습니다. 나는 /etc/hosts
에 항목을 추가 할 suggestion을 발견스레드 "main"에서 java 예외 java.net.UnknownHostException : 테스트 : 테스트 : 알 수없는 오류 OS 우분투
myip localhost
127.0.0.1 localhost
127.0.1.1 test5
하지만 내 오류가 여전히 해결되지 않습니다.
내 코드 :
import java.net.*;
public class InetAddressTest {
public static void main(String args[]) throws UnknownHostException {
InetAddress Address = InetAddress.getLocalHost();
}
}
오류 :
Exception in thread "main" java.net.UnknownHostException: Sachin: Sachin: unknown error
at java.net.InetAddress.getLocalHost(InetAddress.java:1484)
at InetAddressTest.main(InetAddressTest.java:6)
Caused by: java.net.UnknownHostException: Sachin: unknown error
at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:907)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1302)
at java.net.InetAddress.getLocalHost(InetAddress.java:1479)
... 1 more