10 Replies Latest reply: Feb 6, 2007 11:30 AM by 807599 RSS

    MalformedURLException when creating URL?

      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...