Image Creation Problem

Hi,

I am using EclipseME version 1.7.0 with Sun Wireless Toolkit 2.5.1. I have tested EclipseME with Sun WTK by creating a simple HelloWorld Midlet and it works.

However, I am not able to create images and get the following exception:

java.io.IOException

at javax.microedition.lcdui.ImmutableImage.getImageFromStream(+15)

at javax.microedition.lcdui.ImmutableImage.<init>(+20)

at javax.microedition.lcdui.Image.createImage(+8)

at org.j2me.utils.ImageUtils.loadImage(+23)

at org.j2me.game.ImageCanvas.<init>(+9)

at org.j2me.game.HelloMidlet.<init>(+12)

at java.lang.Class.runCustomCode(+0)

at com.sun.midp.midlet.MIDletState.createMIDlet(+34)

at com.sun.midp.midlet.Scheduler.schedule(+52)

at com.sun.midp.main.Main.runLocalClass(+28)

at com.sun.midp.main.Main.main(+80)

The constructor in my canvas is as follows:

public ImageCanvas()

{

try{

Image image = Image.createImage("/logo.png");

}catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}

I create an instance of my canvas in my midlet and then adds it to the Display

Display.getDisplay(this).setCurrent(canvas);

My project structure is as follows:

HelloImage

- src

- res

- deployed

- verified (+sub folders)

I understand that you need to have all your images under the res folder. I also confirmed that the res folder is present in the jar file.

Can anyone suggest why i get the above exception while doing this.

Thnx.

Yogesh

[2014 byte] By [Yogesh_Jankeea] at [2007-11-27 10:00:44]
# 1
Put your images in res folder and specify path as/res/......................hope informative
shejissa at 2007-7-13 0:32:18 > top of Java-index,Java Mobility Forums,Java ME Technologies...