×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    2

    Problems loading images from files

    I have an image wich I wanna load from a file, but I can't because I have a "java.io.IOException: Cannot read file" at runtime. I have a method like this to load the image:

    private Image loadImageFile(String file)
    {
    try
    {
    return ((Image) Image.createImage(file));
    }
    catch(IOException e)
    {
    System.out.println("Can't load image " + file);
    System.out.println("mensaje:" + e.getMessage());
    e.printStackTrace();
    return null;
    }

    and I call it this way "splash = this.loadImageFile("/logo.png""
    What's going wrong?My image files are in a "res" named directory and I this code used to work properly a few days ago.
    Any ideas?

  2. #2
    Registered User
    Join Date
    Mar 2003
    Posts
    5

    RE: Problems loading images from files

    you said that your image files are in a "res"directory, but i always put my image files in a "class" or a "src" directory.

  3. #3
    Regular Contributor
    Join Date
    Mar 2003
    Location
    Rome, Italy
    Posts
    53

    RE: Problems loading images from files

    hi,
    i've my images in the res directory,
    when you build the jar file with nokia dev suite,
    you have to include images in the project.
    have you done this?

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    9

    RE: Problems loading images from files

    If your source code is in a package you'll have to prepend that package name in front of the .png file name in order for your program to find them. Use winzip to have a look inside the .jar file so you can see what the structure is.

    Isomaltine.

Posting Permissions

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