Jump to content

UnknownHostException in Java

KaustubhNajan's Photo
Posted Feb 09 2013 03:10 AM
1794 Views

Hi all, I am accessing server through the java program, it is giving UnknownHostException. I tried the following code..

try{
	//My code..
}catch(UnknownHostException e) {
	System.out.println("Host not found.");
}catch(IOException e) {
	System.out.println("Incorrect username or password.");
}catch(Exception e) {
	e.printStackTrace();
}


I don't understand why catch statement is not catching UnknownHostexception, it is giving same error that java.net.UnknownHostEception (I have imported java.net.UnkonwnHostException class)..

Please help me how to figure out with this exception...

0 Replies