Results 1 to 4 of 4
  1. #1
    himanwish is offline Member
    Join Date
    Mar 2011
    Posts
    7
    Rep Power
    0

    Default MalformedURLException

    Hi Guys,

    Could anyone tell me what's wrong with the below code as I'm getting two compilation errors?

    import java.net.URL;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;

    public class ImageGreeter{

    public static void main (String [] args){

    try{
    URL imageLocation = new URL("http://horstmann.com/bigjava/duke.gif");
    JOptionPane.showMessageDialog(null, "Hello", "Title", JOptionPane.PLAIN_MESSAGE, new ImageIcon(imageLocation));
    }
    catch (MalformedURLException e){
    System.out.pritnln(e);
    }
    System.exit(0);



    }


    }

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by himanwish View Post
    Hi Guys,

    Could anyone tell me what's wrong with the below code as I'm getting two compilation errors?
    Oh, the suspense! Don't make us guess, what are the compilation errors?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,097
    Rep Power
    20

    Default

    I liek the mismatch between the title and the problem.
    The title implies a runtime exception...the problem implies they haven't imported MalformedURLException ... at least that's what I'm placing my money on.
    :)

  4. #4
    ankit mittal is offline Member
    Join Date
    Mar 2011
    Posts
    1
    Rep Power
    0

    Thumbs up Reply to the Exceptions:

    Hi,

    As you said that you are getting 2 Exceptions.here are the exceptions and solution:
    1)MalformedURLException:Import the import java.net.MalformedURLException;
    2)change the spelling of println correctly.....

Similar Threads

  1. java.net.MalformedURLException: no protocol:
    By john_thomas03 in forum New To Java
    Replies: 3
    Last Post: 07-27-2010, 07:28 AM
  2. java.net.MalformedURLException: unknown protocol: ntp
    By Nicholas Jordan in forum Networking
    Replies: 6
    Last Post: 12-24-2008, 03:35 AM
  3. why do I get java.net.MalformedURLException ?
    By aneuryzma in forum New To Java
    Replies: 3
    Last Post: 08-14-2008, 11:57 AM
  4. java.net.MalformedURLException
    By mary in forum Advanced Java
    Replies: 1
    Last Post: 07-13-2007, 04:37 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •