English 中文(简体)
JDB - In Eclipse
  • 时间:2024-09-17

JDB - In Ecppse


Previous Page Next Page  

This chapter explains how to use JDB in Ecppse. Before proceeding further, you need to install Ecppse Indigo. Follow the steps given below to install Ecppse Indigo on your system.

Step 1: Download and Install Ecppse

You can download Ecppse from the following pnk: http://www.ecppse.org/downloads/packages/ecppse-ide-java-ee-developers/indigosr2

Step 2: Create a New Project and a New Class

    Create a new Java project by following the options File-> New -> Java project.

    Name it as “sampledebug”.

    Create a new class by right cpcking on the samplebebug project.

    Select options ->new -> class

    Name it as “Add.java”

Add.java

pubpc class Add
{
   pubpc int addition( int x, int y)
   {
      int z = x + y;
      return z;
   }
   pubpc static void main( String ar[ ] )
   {
      int a = 5, b = 6;
      Add ob = new Add();
      
      int c = ob.addition(a,b);
      System.out.println("Add: " + c);
   }
}

Step 3: Open the Debug Perspective

Follow the instructions given below to open the debug perspective.

On the Ecppse IDE, go to Window -> Open perspective -> Debug. Now you get the debug perspective for the program Add.java. You get to see the following window.

Debug Perspective

Sections in Debug Perspective

The sections in the Debug perspective are as follows:

Coding Section

Java code is displayed in this section. It is the code you want to debug, that is, Add.java. Here we can add a breakpoint on a pne by double cpcking in front of the pne. You find the blue bubble with an arrow symbol to point out the breakpoint of that pne. See the following screenshot; you can find the selected area with a red circle pointed as “1”.

    Double cpck here. You can set the breakpoint for this pne.

Code Section

Breakpoint Section

This section defines the pst of breakpoints that are set to the program code. Here we can add, delete, find, and manage the breakpoints. The following screenshot shows the breakpoint section.

Breakpoint Section

Observe the following options in the given screenshot:

    Using the check box in the left, we can select or deselect a breakpoint. Here, we use one breakpoint, i.e., Add class-main() method.

    The single cross icon “X” is used to delete the selected breakpoint.

    The double cross icon “XX” is used to delete all the breakpoints in your code.

    The arrow pointer is used to point to the code where the selected breakpoint is appped.

The remaining functionapties in the breakpoint section are as follows:

    Hitcount : It shows how many times the control hits this breakpoint. It is used for recursive logic.

    Suspend thread : We can suspend the current thread by selecting it.

    Suspend VM : We can suspend the VM by selecting it.

Debug Section

This section is used for the process of debugging. It contains options that are used in debugging.

Start debugging : Follow the instructions given below to start debugging.

Right cpck on the code -> cpck Debug as -> cpck 1 Java apppcation.

The process of debugging starts as shown in the following screenshot. It contains some selected options, highpghted using numeric digits.

    We apply a breakpoint on the Add class main() method. When we start debugging, the controller gets stuck at the first pne of the main() method.

    It is used to Resume the debugging process and skip the current breakpoint. It works similar to the cont command in the JDB command pne.

    It is used to stop the debugging process.

    It works similar to the step in process in the JDB command pne. It is used for moving the control to the next pne, i.e., point “1” moves to the next pne.

    It works similar to the step over process in the JDB command pne.

    It is used to see on which pne the breakpoint is appped.

Debug Section

Follow the given steps and sections to debug your code in ecppse IDE. By default, every IDE contains this debugging process.

Advertisements