Results 1 to 7 of 7
  1. #1
    Join Date
    May 2012
    Location
    Malta
    Posts
    1
    Rep Power
    0

    Default Java ImageIO Method | What's wrong in my code !!!

    Hi!
    There must be something wrong with my code as terminal is not loading.
    Any Help would be appreciated !!! Thanks.

    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;

    class HappyMothersDay
    {
    public HappyMothersDay()
    {
    try
    {
    BufferedImage image = ImageIO.read(new File("C:/Users/Isaac/Pictures/etc.png")); // insert image root, folders, subfolders, file. jpeg, png, etc
    }
    catch (IOException e)
    {
    }
    }
    public static void main (String args[])
    {
    new HappyMothersDay();
    }
    }

  2. #2
    Art Vandelay is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    Hi Isaac,
    Quickly scanning... try replacing...

    ImageIO.read(new File("C:/Users/Isaac/Pictures/etc.png"));

    with

    ImageIO.read(new File("C://Users//Isaac//Pictures//etc.png"));

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    Quote Originally Posted by Art Vandelay View Post
    Hi Isaac,
    Quickly scanning... try replacing...

    ImageIO.read(new File("C:/Users/Isaac/Pictures/etc.png"));

    with

    ImageIO.read(new File("C://Users//Isaac//Pictures//etc.png"));
    No, sorry, but I don't think that this will solve anything. Hang on...

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    Quote Originally Posted by ProgrammerIsaac View Post
    Hi!
    There must be something wrong with my code as terminal is not loading.
    Any Help would be appreciated !!! Thanks.

    Java Code:
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    
    class HappyMothersDay
    {
    public HappyMothersDay()
    {
    try
    {
    BufferedImage image = ImageIO.read(new File("C:/Users/Isaac/Pictures/etc.png")); // insert image root, folders, subfolders, file. jpeg, png, etc
    }
    catch (IOException e)
    {
    }
    }
    public static void main (String args[])
    {
    new HappyMothersDay();
    }
    }
    Please show the rest of your code with code tags if possible. Please tell us about any errors or exceptions that occur and post the complete messages.

  5. #5
    Diargg is offline Senior Member
    Join Date
    Feb 2012
    Posts
    117
    Rep Power
    0

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    It's self contained and references no non-standard libraries. I think this is the entire program. Isaac - can you point out which line of code is supposed to load your terminal?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,331
    Rep Power
    25

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    terminal is not loading.
    Can you explain what is not happening?

    One problem I see is the empty catch block. You should always call the printStackTrace() method in catch blocks to show any error messages.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Art Vandelay is offline Member
    Join Date
    May 2012
    Posts
    18
    Rep Power
    0

    Default Re: Java ImageIO Method | What's wrong in my code !!!

    Hi Issac,

    I ran you code--with a few alterations (see below)...and it worked. The terminal opened, etc.

    However, please note that your class only generates a "BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered." Your code doesn't currently do anything with the BufferedImage.

    The exact code I used was:
    Java Code:
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    
    class HappyMothersDay
    {
    public HappyMothersDay()
    {
    try
    {
    	BufferedImage image = ImageIO.read(new File("D:\\Images\\blank.jpg"));
    }
    catch (IOException e)
    {
    	System.out.println( "Error " + e);
    }
    }
    public static void main (String args[])
    {
    new HappyMothersDay();
    }
    }
    Did you wish to do something with the image once your read it?

    Or...if your terminal isn't opening...are you sure it is compiling?

    If it is not reading the image--because it is not there...the error would be:

    Java Code:
    Error javax.imageio.IIOException: Can't read input file!
    BW, ArtV
    Last edited by Art Vandelay; 05-22-2012 at 09:07 PM.

Similar Threads

  1. Replies: 32
    Last Post: 02-29-2012, 09:21 AM
  2. What is wrong in this code of java
    By kank635 in forum New To Java
    Replies: 1
    Last Post: 01-16-2012, 09:41 PM
  3. How to call an XML-RPC method from Java Code
    By sreekanth.srk in forum Enterprise JavaBeans (EJB)
    Replies: 0
    Last Post: 12-31-2010, 12:36 PM
  4. Please look at my java code and tell me what's wrong
    By xcointoss in forum Advanced Java
    Replies: 3
    Last Post: 10-22-2010, 04:15 AM
  5. what wrong with my java code
    By MAXZZXAM in forum New To Java
    Replies: 3
    Last Post: 11-19-2009, 09:38 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
  •