Developing Java Applications: A Tutorial | Debugging Java Applications

Preparing to Debug an Application

Before you can debug a Yellow Box Java application, you must build the application with the proper debugging symbols and then run the Java Debugger, after which you can set breakpoints and begin debugging.

Install Debug Libraries on Windows NT

To debug "wrapped" frameworks of yours on Yellow Box for Windows systems, you must first install the debug versions of the Yellow Box libraries (DLLs).

Important
If you have a Mac OS X system, you do not need to complete this task. Skip ahead to the next task, Build for Debugging .

  1. Click the Inspector button on the main window:



  2. In the Build Attributes display of the Project Inspector, select Build Targets from the middle pop-up menu.
  3. Enter "install_debug" in the text field and click Add.



  4. To get the Build panel, click the Build button on Project Builder's main window:



  5. Click the Options button on the Build panel:



  6. Choose "install_debug" from the Target pop-up menu.
  7. Click the Build button on the Build panel to install the debug libraries.

Build for Debugging

  1. Display the Build Options panel.
    1. Click the Build button on Project Builder's main window:
    2. Click the Options button on the Build panel:



  2. Set the debug target.

    Select the debug item from the Target pop-up menu, as shown in the illustration below:

  3. Remove object files and other files generated by previous builds by clicking the "make clean" button. This step is necessary only if you had previously built an application executable without debugging symbols.)

    The "make clean" button on the Build panel looks like a broom:

  4. Build the project.

Access the Java Debugger

When you have built the project and have an executable containing symbols understood by jdb , run the Java Debugger from Project Builder. Project Builder knows which debugger to run, based on the type of executable it is debugging.

For the following exercise, assume that you are debugging a program containing only (or mostly) Java code, such as Temperature Converter.

  1. Click the Launch button on Project Builder's main window:

    This brings up the Launch panel.

  2. Make sure that gdb is turned off as a debugging feature.
    1. Click the Options button on the Launch panel:

    2. Click the Debugger tab to display the debugger options; make sure that the Java Debugger checkbox is marked and the gdb checkbox is not marked.

    Important
    The Java Debugger is automatically selected when your project contains Java code. The gdb debugger is also selected if the "Use GDB when debugging Java programs" preference (in the Debugging display of the Preferences panel) is selected. If you do not want gdb active when you debug Java programs, turn off this preference.

  3. Click the Debug button on the Launch panel.



The Java Debugger starts up and displays its "JavaDebug>>" prompt. Because the Java VM is an interpreter, you do not need to suspend the Java Debugger to perform tasks such as setting breakpoints. You can, however, suspend and resume the Java Debugger if you wish. The Suspend/Continue button looks like this in Suspend mode (in the setting of its neighboring controls):

And in Continue mode the button looks like this:


Previous | Next
© 1998 Apple Computer, Inc.