Skip to Main Content

New to Java

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!

MalformedURLException when creating URL?

807599Feb 6 2007 — edited Feb 6 2007
Hi. Does anyone know why Netbeans 5.5 gives me a MalformedURLException EVERY time I write code to create a URL??

It red-underlines my code and says "unreported exception java.net.MalformedURLException; must be caught or declared to be thrown".

I haven't even run my code yet... There is nothing wrong with the URL or the String object (if applicable) I am using. It doesn't matter whether I use a valid URI's .toURL() method, or if I use a
new URL(anotherURL.toString())
.

If I enclose the whole thing in a try...catch, it takes away the red-underline and it works just fine when I run it... even though it never catches the exception.

Is this a NetBeans bug, a Java bug, or should I just be doing something differently?

Thanks for any feedback...
-RN
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 6 2007
Added on Feb 6 2007
10 comments
1,701 views