redhat01
redhat01

Reputation: 135

How to see the execution steps of a java program

I know that Eclipse have a function that allow us to see the steps of execution of a program.

Can anyone tell me how can I find it? I really need it to study and understand some pices of code.

Upvotes: 1

Views: 8449

Answers (2)

PrR3
PrR3

Reputation: 1246

Executing your java program step by step you need to follow a few steps:

  • Set a breakpoint by double-clicking left of the very first line of your program, which seems to be something like public static void main(String[] args). The breakpoint looks like this -> enter image description here
  • Open your program in the enter image description here view. (in the standard layout this could be found in the top right corner of your eclipse ide)
  • Start running your program in debug mode enter image description here (in the standard layout this could be found in the toolbar at the top of your eclipse ide)
  • Now you can easily navigate through your program by using the F5-F7 buttons or clicking these icons in the top toolbar enter image description here

For deeper insight look at the tutorial Here

Upvotes: 5

xrdty
xrdty

Reputation: 886

Look for the little green bug at the top. If you run it by pressing this icon, your application will run in a new perspective and stop at your breakpoints.

enter image description here

Enter breakpoints by clicking the area where you see the blue dot in this picture.

enter image description here

Navigate inside of the debugger with:

enter image description here

Green arrow is for running till next breakpoint. Red square is for terminating the process. The 90degree arrow goes into methods you invoke showing each step IN the method. The last arrow executes them without showing the steps.

If you're done with debugging you can switch perspective here.(upper right corner) enter image description here

Upvotes: 7

Related Questions