How to use exception stack trace after process dead
An example: let's suppose I have a piece of code like this:
to[m][k]=from[i][k];
then a开发者_运维百科t execution it launches a NullPointerException at that line of code... Ok, then debugger ends and I can't read variables that caused the exception and moreover in that line of code there are 4 index operations so I can't understand which one of the 4 really caused the exception.
Thank you- put a breakpoint on that line
- ask netbeans to stop on exceptions: Tools -> Miscellaneous -> Java Debugger -> General and check "Stop on uncaught exception".
Any particular reason why you are not setting break points?
In this case, if you set a break point at to[m][k]=from[i][k];
, the program will break at this point giving you a chance to read m
and i
values
You can set a breakpoint and then set its properties to break on exception. That will give you a chance to see what's going on.
If that line is down inside a bunch of nested loops, I could imagine you wouldn't want a breakpoint there.
In eclipse, you can set breakpoints on exceptions in addition to on particular lines of code. I'd look for a similar feature in NetBeans.
精彩评论