IllegalAccessException starting my J2ME app
I have this code in Test.java:
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
import javax.microedition.lcdui.game.*;
publicclass Testextends MIDletimplements CommandListener
{
TestCanvas canvas;
public Test(){}
publicvoid startApp()
{
canvas =new TestCanvas(Display.getDisplay(this));
canvas.addCommand(exitCommand);
canvas.setCommandListener(this);
canvas.start();
}
publicvoid destroyApp(boolean unconditional)throws MIDletStateChangeException
{}
publicvoid pauseApp()
{}
private Command exitCommand =new Command("Exit", Command.EXIT, 99);
publicvoid commandAction(Command c, Displayable s)
{
if(c == exitCommand)
{
try
{
destroyApp(false);
notifyDestroyed();
}
catch (MIDletStateChangeException ex)
{}
}
}
}
class TestCanvasextends GameCanvasimplements Runnable
{
Display display;
public TestCanvas(Display d)
{
super(false);
display = d;
}
void start()
{
display.setCurrent(this);
repaint();
}
publicvoid run()
{
Graphics g = getGraphics();
while (true)
{
g.setColor(0x0000FF);
g.fillRect(0, 0, getWidth(), getHeight());
g.setColor(0xFFFFFF);
int keyState = getKeyStates();
if ((keyState & LEFT_PRESSED) != 0)
{
g.drawString("left", 0, 0, 0);
}
elseif ((keyState & RIGHT_PRESSED) != 0)
{
g.drawString("right", 0, 0, 0);
}
flushGraphics();
}
}
}
When I build it with the Wireless Toolkit and run it in the emulator, I get this in the WTK window:
Unable to create MIDlet Test
java.lang.IllegalAccessException
at com.sun.midp.midlet.MIDletState.createMIDlet(+34)
at com.sun.midp.midlet.Selector.run(+22)
If I try it on my cell phone (Sony Ericsson W300i), it just gives me a blank white screen.
Any ideas on what's going on?

