This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

exception with ImageItem

 
Ajeesh Moidutty
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used this code :
////////////////////
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class ImmutableImageFromFile extends MIDlet implements CommandListener
{
private Display display;
private Form fmMain;
private Command cmExit;
public ImmutableImageFromFile()
{
display = Display.getDisplay(this);
cmExit = new Command("Exit", Command.EXIT, 0);
fmMain = new Form("");
fmMain.addCommand(cmExit);
fmMain.setCommandListener(this);


try
{
Image im = Image.createImage("1.jpg");
fmMain.append(new ImageItem("asd", im,ImageItem.LAYOUT_DEFAULT, "asdf"));
display.setCurrent(fmMain);
}
catch (java.io.IOException e)
{
e.printStackTrace();
}
}
public void startApp()
{
display.setCurrent(fmMain);
}
public void pauseApp()
{
}
public void destroyApp(boolean unconditional)
{
}


public void commandAction(Command c, Displayable s)
{
if (c == cmExit)
{
destroyApp(false);
notifyDestroyed();
}
}
}
\\\\\\\\\\\\\\\

on running it i got this 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 ImmutableImageFromFile.<init>(+75)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)
////////////////

What does that mean?
 
Koh Khai Huat
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ajeesh Moidutty,

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 ImmutableImageFromFile.<init>(+75)
at java.lang.Class.runCustomCode(+0)
at com.sun.midp.midlet.MIDletState.createMIDlet(+19)
at com.sun.midp.midlet.Selector.run(+22)

the error above mean that the input / output of the program had an exception which may point to the image file that the program is loading may not be
found check if the image is found or not

rgards Khai Huat
 
Rush IT
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try with png image instead of .jpg
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic