0

In a previous question I had asked about recursion one of the responses recommended that I use debugger mode to see the order of operations. I had a few more order of operations questions, but figured I should use the debugger to run it instead of asking silly questions each time.

I ran the application in "Debug As" -> "Java Application" in Eclipse, and it just runs the program in a normal console giving me the same result as if I were to run it.

This is the program in question(Just what I am using to test Debug, I don't have questions regarding this actual app):

public class main {
public static void main(String [] args){
System.out.println(fact(5));

}

public void fact()
{
fact(5);
}

public static int fact(int n)
{
if(n == 1){
    return 1;
}
return n * (fact(n-1) + 5);
}
}

In Debug mode it just provided me with "1145", which is the same thing that the normal "Run" mode provides me.

I wanted to see the actual step by step instructions that are being fed into the JVM, which is what I gathered that Debug is supposed to do.

I read online instructions on how to Debug applications, and that tutorial had different options in Eclipse then mine, such as "toggle breakpoint", which I do not have in the most recent version of Eclipse.

Can someone please point me to a direction as to how to get Eclipse to show me step-by-step operations.

LearnIT
  • 336
  • 2
  • 7
  • 23
  • It seems learning how to debug is an art of it's own. I was thinking it would just say 5*(5-1) etc, until it gets to the final answer – LearnIT Jun 05 '13 at 18:20

3 Answers3

2

You need to add debug points in your code.see how to debug

Sanjaya Liyanage
  • 4,706
  • 9
  • 36
  • 50
2

In Eclipse you double-click in the left margin beside a line and it will set a breakpoint at that line and mark it.

When you run in debug mode, it will stop when it gets to a line with a breakpoint and you can look at the stack and variable values and what-not. A whole new perspective will try to pop up when it hits that breakpoint that has lots of windows with interesting info.

Lee Meador
  • 12,829
  • 2
  • 36
  • 42
2

If you double-click in the left margin, you can set a breakpoint. It will appear as a blue dot.

betseyb
  • 1,302
  • 2
  • 18
  • 37