Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: acm.util.ErrorException: Cannot find image named

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Question acm.util.ErrorException: Cannot find image named

    I am using Eclipse Galileo. I have a class that should display a deck of cards face down but the image for the card is not found at runtime. I first placed the image inside a folder named "images" inside the project folder. Then I tried placing the image in the same package as the classes but still no luck. The error messages are the same, image not found. I even tried to import the images folder but eclipse recognises the folder and image within the hierarchy of the project and will not allow the import. My question is if it is seen by Eclipse during save/compile, why is it not seen at runtime? What am I missing? I am thinking maybe I have to specify a path as part of the file name, or maybe there is a default location java will seek images. Or ...

    If I just use a filled rectangle in place of the image, everything runs fine. By the way, I am toying with the acm package, because I am new to java, and it was introduced to me as "the way to do it". I am seeing its not all it is cracked up to be. I plan to start using java.awt.Image soon. Perhaps now.


  2. #2
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: acm.util.ErrorException: Cannot find image named

    Please post how you are trying to access the images. If you call getResource, the path specified must be relative to the package. So if you package an image into a jar at the root location (not in a package), the you call
    getResource("/myimage.jpg");
    if the are in a folder called images, then
    getResource("/images/myimage.jpg");
    Note the first slash, indicating the root path of the jar.

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    8
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: acm.util.ErrorException: Cannot find image named

    Quote Originally Posted by copeg View Post
    Please post how you are trying to access the images...
    acm package's GImage as follows:
    GImage deck = new GImage("CARD_DECK_BASIC.jpg");

    I am learning more and more about awt's Image class and it seems a better way to go. Perhaps for now I should step back and think. Any suggestions on a way to handle this?

    I am trying to display this image on the back of a deck of cards. The jpg is smaller than the display size so it will need the scale method. As well as getting the location and other useful methods I find in awt. I guess I am wondering if there is a better way to handle a single image multiple times than the Image class.

Similar Threads

  1. Replies: 3
    Last Post: April 26th, 2011, 02:51 AM
  2. Stupid thing can't find image icon right in front of it!!!
    By javapenguin in forum What's Wrong With My Code?
    Replies: 14
    Last Post: July 9th, 2010, 01:02 AM
  3. java.util.* and visual studio 2005
    By natalie in forum Java Theory & Questions
    Replies: 0
    Last Post: February 26th, 2010, 10:34 AM
  4. Pixel Alteration in an image/image rotation
    By bguy in forum Java Theory & Questions
    Replies: 3
    Last Post: November 1st, 2009, 10:50 AM
  5. Replies: 4
    Last Post: April 29th, 2009, 10:53 AM