开发者

How do I setup Eclipse to stop on the line an exception occurred?

How can I setup Eclipse to stop at the point an exception occurred.

I have an Eclipse breakpoint setup to break on an exception. In the code example below, the problem I'm having is Eclipse tries to open the Integer source code. Is there any way to just have debugger break at the point shown in my code example? If I move down the stack trace, I will get to this line, it'd be nice if there's a way to do this without the "Source not found" window coming up.

This can be done in Visual Studio, so it's driving me crazy not being able to find a way to do this in Eclipse.

package com.test;

public class QuickTest
{
  public static void main(String[] args)
  {
    try
    {
        test();
    }
开发者_开发技巧    catch(NumberFormatException e)
    {
        System.out.println(e.getMessage());
    }
 }

  private static void test()
  {
    String str = "notAnumber";

    Integer.parseInt(str);//<----I want debugger to stop here
  }
}

 


I'm not sure how else to get there, but I just do:

Window -> Show View -> Breakpoints

And in that tab there is a "J!" that lets you set breakpoints on exceptions.

How do I setup Eclipse to stop on the line an exception occurred?


Preferences -> Java -> Debug -> Step Filtering Choose packages you want to filter out when debugging (java.*, sun.*, etc) On debug make sure the little step filtering arrow is selected.

This should do the trick.


  1. Can't you just set a breakpoint on the Integer.parseInt(str) line?
  2. If you point your Eclipse project at using a JDK instead of a JRE it should pick up the source code for all of the platform classes (Integer etc).


The Debug view will show the entire stack of the current execution. You need to select the line you want to see. It will be same as you had a breakpoint there, you can see all the variables etc.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜