JDB Stepping

JDB Stepping with Introduction, JDB Tutorial, Architecture, Installation, Expression, Connection, Commands, Example, Breakpoint, Stepping, Options, Exception Handling etc.

JDB Stepping

JDB Stepping

Stepping is a very common method of debugging that executes the code line by line. So, this approach can be used when there is a requirement to check one line at a time. It simply controls the flow of program.

Techniques of Stepping

There are three techniques of stepping:-

  • Step Over
  • Step Into
  • Step Return

Step Over

In this approach, the particular line where the program is paused will get executed and now the program will paused on the next line.

Step Into

In this technique, debugger entered into the method and start debugging line by line by using step over approach.

Step Return

Once the method is debugged, step return is used to exit the control of program from that particular method.

Through this example, we will try to understand the JDB stepping.


  1. public class JStep  
  2. {  
  3. int square(int a)  
  4. {  
  5. return a*a;  
  6. }  
  7. public static void main( String...jtp)  
  8. {  
  9. JStep obj=new JStep();  
  10. System.out.println("Square of given number : "+obj.square(4));  
  11. }  
  12. }  


  • Compile the above program and create a JDB session.
  • Now, set the breakpoints.
  • Run the debugger by using the following command: -
  1. >run JStep  


Now use the following command to step up the execution to next line: -

  1. >step 

Then use the below command to find out the position where the control has been reached.

  1. > list  

If you notice in the below screenshot, the arrow (=>) indicates the current position of program control.

To continue the execution of code follow the below command

  1. >cont