Manuel Debugging af J2ME kode
Er der nogen derude der ved hvordan man man "manuelt", dvs uden brug af en IDE, debugger J2ME kode, her taenker jeg specifikt paa at saette et breakpoint og saette et watch paa en variabel, og faar denne information skrevet ud ?Flg kode er et HelloWorld eksempel hvor jeg har markeret et sted hvor et breakpoint kunne indsættes og hvor jeg gerne vil have skrevet værdien af "test" ud.
Yderligere kan jeg nævne at J2ME eller MIDP om man vil, understøtter Java Debug Wire Protocol (JDWP).
package test;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class Test extends MIDlet implements CommandListener {
private Command exitCommand; // The exit command
private Display display; // The display for this MIDlet
public Test() {
display = Display.getDisplay(this);
exitCommand = new Command("Exit", Command.SCREEN, 2);
}
public void startApp() {
TextBox t = new TextBox("Hello MIDlet", "Test string", 256, 0);
t.addCommand(exitCommand);
t.setCommandListener(this);
/*BREAKPOINT OG WATCH/ELLER UDSKRIVNING AF LOKALE VARIABLE*/
int tester = 5;
tester++;
display.setCurrent(t);
test++;
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable s) {
if (c == exitCommand) {
destroyApp(false);
notifyDestroyed();
}
}
}
