In Eclipse, you can debug your application, either by connecting a real BlackBerry device via the USB cable, or you can download a BlackBerry simulator and use it to test your app. Note that BlackBerry simulators only are supported on Windows.
Once you start debugging, you should see the Eclipse Debug perspective. Normally, one of the open windows in Eclipse will be the Console window. If you don't see that, use the Eclipse menu:
Window -> Show View -> Console
While your app runs (or your device is connected), you should see output in the Console window like this:
[0.0] JVM: bklt[1]: setTimeout 120
[0.0] JVM: bklt[1] @438007: JBSC on=0
[0.0] JVM: bklt[1] @438007: SC 0
[0.0] JVM: bklt[1]: setTimeout 120
[0.0] VM:TRJFp=net_rim_services_impl
[0.0] net_rim_crypto_1-3(4CC8AA32)
[0.0] StatusClean
Any standard output that your program creates (e.g. System.out.println()
) will be mixed in with these messages from the OS.
Normal java.lang.Exception
objects in BlackBerry have much of the useful information removed, so if you don't know what kind of exception is being thrown, or where, you can choose to debug the problem by simply catching all java.lang.Throwable objects in your app's main program:
public static void main(String[] args) {
try {
Application app = new MyApp();
app.enterEventDispatcher();
} catch (Throwable t) {
t.printStackTrace();
}
}
public MyApp() {
ButtonScreen bs = new ButtonScreen();
pushScreen(bs);
bs.throwException(); // <- for test purposes!
}
Then, you'll see something like this in your Console window and can find out what's going wrong in your code:
[0.0] FocusHistory: Focus gained; App HelloBB; Component mypackage.ButtonScreen$1
[0.0] IllegalArgumentException
[0.0] testing exception handling code!
[0.0] HelloBB(51B3A691)
[0.0] ButtonScreen
[0.0] throwException
[0.0] 0x74C
[0.0] HelloBB(51B3A691)
[0.0] MyApp
[0.0] <init>
[0.0] 0x151B
[0.0] HelloBB(51B3A691)
[0.0] MyApp
[0.0] main
[0.0] 0x14B2
[0.0] VM:TRJFp=HelloBB
[0.0] net_rim_cldc-26(4CC89E31)
[0.0] BlockingTimeSource
[0.0] run
[0.0] 0x104D
[0.0] VM:TRJFp=HelloBB
[0.0] net_rim_cldc-26(4CC89E31)
[0.0] BlockingTimeSource
[0.0] run
[0.0] 0x104D
[0.0] VM:TRJFp=HelloBB
[0.0] net_rim_cldc-26(4CC89E31)
[0.0] BlockingTimeSource
[0.0] run
[0.0] 0x104D
in this situation, I put this code:
public void throwException() throws Exception {
throw new IllegalArgumentException("testing exception handling code!");
}
into my app, so that my MyApp#main()
method called the MyApp
constructor, which called the ButtonScreen#throwException()
method.