Results 1 to 5 of 5
  1. #1
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default ImageIO exception problem

    I have this try{ statement to load an image:
    Java Code:
            try {
                File file = new File("image.jpg");
                Image img = ImageIO.read(file);
            } catch (IOException ex) {
                Logger.getLogger(Paint.class.getName()).log(Level.SEVERE, null, ex);
            }
    My problem is that even after NetBeans asks me to put this block in a try-catch and it does that, it just keeps asking me to put this block of code in a try-catch. Why?

  2. #2
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    11,802
    Rep Power
    19

    Default

    What exactly is NetBeans saying.
    Because it will also be telling you what exception it thinks you are not currently catching.

  3. #3
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default

    Yes, thanks i have fixed that now. I put it in its own method and it seems to be working but now the image still wont paint.

  4. #4
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    You might want to check that the file .exists() and, if it doesn't, print the full path that you are looking at when you call new File("...").

  5. #5
    jammas615 is offline Senior Member
    Join Date
    Jul 2011
    Location
    Melbourne, Victoria, Australia
    Posts
    155
    Rep Power
    4

    Default

    Thanks for your help, it turned out i wasn't even calling my getImages() function that holds the code above. I now have it called in the constructor and i had to print the full path :)
    Last edited by jammas615; 07-06-2011 at 11:56 AM.

Similar Threads

  1. How to install com.sun.media.imageio.plugins
    By Shellback3 in forum Eclipse
    Replies: 0
    Last Post: 05-12-2011, 06:01 PM
  2. Error with ImageIO
    By stegano in forum New To Java
    Replies: 4
    Last Post: 03-31-2011, 03:59 PM
  3. BufferedImage, ImageIO and Jar files
    By satory in forum New To Java
    Replies: 6
    Last Post: 05-23-2010, 12:07 AM
  4. Trouble with ImageIO
    By sari in forum New To Java
    Replies: 1
    Last Post: 03-30-2009, 09:42 PM
  5. Help with ImageIO
    By romina in forum AWT / Swing
    Replies: 1
    Last Post: 08-07-2007, 05:21 AM

Posting Permissions

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