Home Step 06

Compiling, running, and debugging tutorial

Step 7: Finding runtime exceptions

In this step of the tutorial, you'll see what happens when a runtime exception is generated. The sample program does not do any error handling. For example, if you enter a character in the Value 1 or Value 2 fields instead of a number, the program will generate a runtime exception stack trace. It won't gracefully tell you that the value was not the expected format or provide information about valid values.

To see what a runtime exception stack trace looks like,

  1. Run the program.

  2. Enter eeee in the Value 1 input field. Enter 3 in the Value 2 input field. Press Compute Values.

  3. Minimize the program to view the message pane.

    The Application1 tab now displays a NumberFormatException stack trace. This is a trace of how your program arrived at this exception. Scroll to the top of the pane.

  4. This step is for JBuilder Professional and Enterprise users only.

    Click the first class name in the stack trace to see where the exception is thrown. In this case, click java.lang.FloatingDecimal.

    JBuilder opens the source code for java.lang.FloatingDecimal and highlights the line of code where the exception is thrown.

    You can click other classes in the stack trace to trace through the steps that brought the program to this exception.

To handle this exception is beyond the scope of this tutorial. To run the program again without the exception, just close the program and run it again entering numeric values.

Congratulations, you have finished this tutorial. You found and fixed syntax errors, compiler errors, and runtime errors using JBuilder's integrated debugger. You also saw an example of a runtime exception stack trace.

For more information on compiling, running, and debugging, read the following chapters in the online Help book, Building Applications with JBuilder:

For suggestions on improving this tutorial, send email to jpgpubs@inprise.com.

Home Step 06