开发者

How to use exception stack trace after process dead

probably my question is due to my "beginnery"; however... I'm using netbeans and I wrote a project. Then I start my project with debugger but without break points, hoping that at exception occurrence I could eventually read variable values to understand which instruction is the problem.

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


  1. put a breakpoint on that line
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜