LearnIT
LearnIT

Reputation: 346

How To Run Eclipse Debugger Mode to See Order of Operations?

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.

Upvotes: 0

Views: 519

Answers (3)

betseyb
betseyb

Reputation: 1332

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

Upvotes: 2

Lee Meador
Lee Meador

Reputation: 12985

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.

Upvotes: 2

Sanjaya Liyanage
Sanjaya Liyanage

Reputation: 4746

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

Upvotes: 2

Related Questions