23

Am I missing something? I'm delighted that all that code is there showing how the generic collections work etc. However when I want to simply walk my code I'm forever finding myself going deeper into Java's own library code than I care to.

Is it possible to simply disable that when stepping code - I want to treat all of that stuff as a Black Box, code stepping is just for stuff I've written.

And you know what, now I've got that capability, is it possible to wrap up my own code that way too so that I can step just the bits I'm most interested in?

And if i can't easily in netbeans, is it possible in eclipse?

thanks

5 Answers 5

25

Actually, the easiest way is to go to Window -> Debugging -> Sources and check off the files that you want to debug and step in to. Most likely you just need to UNcheck the other sources in your project.

But that's the easiest way to do it.

Sign up to request clarification or add additional context in comments.

1 Comment

This is another way to do it... and a bit easier than defining step filters
15

There are different "stepping" instructions for a debugger:

  • Step over (F8 and Shift+F8 in NetBeans)

    statementA; // step over: to callB
    callB();    // step over: to statementB: it will treat the call as a
                //  black-box.
    statementB;
    
  • Step into (F7 in Netbeans)

    statementA = callA() + 4; // step into: will step into the expression
                              // and start to debug the "callA()" method.
    callB();                  // step into: will step into the "callB()" method.
    statementB;               // some statements don't have anything to step into
    
  • Step out (Ctrl+F7 in Netbeans)

    void methodB() {
        someStatementB; // stepOut will treat the rest of the method as
                        // a black-box, and you will end up at "someStatementC".
    }
    
    someStatementA;
    methodB();
    someStatementC;
    

You'll need to "step over" methods & expressions you want to treat as a black-box.

To automatically "step over" Classes that you don't want:

http://h.imagehost.org/0115/NetbeansStepFilter.png

ToolsOptionsMiscellaneousJava DebuggerStep Filters

⊗ Do not step into

And press Add, and add java.* and javax.*, and all other classes you don't want to debug. This is a "global" setting, and is not per-project!

2 Comments

Thanks. I know that, I just don't want to have to bother when I'm flying through code, it really slows me up having to make that decision. I usually only care about my own code, so I want to configure my debugger to automatically step over files that are not in my project, say, or marked as in scope for debug.
Updated: A step-by-step instruction for setting the Step filters in NetBeans.
4

In eclipse you can define step filters (packages that you don't want to step in during debugging).

You'll find the configuration at "Window/Preferences" and then "Java/Debug/Step Filtering".

3 Comments

That sounds exactly what I'm after thanks. I'm kind of stuck with NetBeans, I did use eclipse in the past (on the back of RSM) and enjoyed my time with it. If I really can't do what I need in NetBeans I'll make the jump back to Eclipse.
You've empowered me! You've given me the term "Step Filters", I've discovered that this capability exists in NetBeans too, somehow the words didn't equate to my requirements, so I skipped over that functionality, but it neatly sums up my requirements! :-)
Why the downvote? The SO asked for a solution in eclipse, too!
3

You can check "step through the filters to reach unfiltered code" in NetBeans 8.0.2

Java Options -> Java Debugger window

Comments

3

NetBeans 6.8 has step filters, too.

Use Tools->Options (NetBeans->Preferences on Mac) to open the Options dialog.. alt text

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.