Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

InetAddress exception errors

843790Dec 21 2007 — edited Dec 21 2007
Hi all

When compiling my program
Following errors getted:-
1.unreported exception java.net.UnknownHostException; must be caught or declared to be thrown
InetAddress inet = InetAddress.getByName("www.davidreilly.com");
2.exception java.net.MalformedURLException is never thrown in body of corresponding try statement
catch (MalformedURLException e){}



This is the part of my code in which errors occur
try {
		  InetAddress inet = InetAddress.getByName("www.davidreilly.com");
		   System.out.println ("IP  : " + inet.getHostAddress());
		}
		  catch (MalformedURLException e){}
Please help me to correct and why unreported exception java.net.UnknownHostException; must be caught or declared to be thrown if I dont use try and catch statements
Thanks in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 18 2008
Added on Dec 21 2007
1 comment
643 views