Eclipse : How to put break points inside a class (outside the method )

391 Views Asked by At
import java.util.Properties;

public class Pavan {
    Properties props = new Properties();
(X) String message = props.getProperty("message");
    String name = message;

    public static void main(String args[]) {
        Pavan k = new Pavan();

    }

}

Hi ,

This is my Sample Program . I am using Eclipse IDE 3.6 version .

i am able to put break points inside the method (Here in this case it is main method ) Here my question is that , cant i put break point at the line (X) String message ??

Please let me know , thanks in advance ??

3

There are 3 best solutions below

4
On

As far as I know, you can't put breakpoints outside of a method. Why would you put a breakpoint at this line? I never tried but it seems you can add watchpoints.

0
On

It is not clear what you exactly mean, however you have several type of breakpoints in Eclipse :

  • Line Breakpoint
  • Exception Breakpoint
  • Classloading Breakpoint
  • Watchpoint
  • Method Breakpoint
  • Printpoint

I think that maybe you need a Watchpoint in your case ...

0
On

A breakpoint can be set outside of a class when there is executable code. Like in the initializer statement (can't think of any other example...) in the example you gave. Trying it out with eclipse reveals, that the it is possible to choose "toggle breakpoint" from the contextmenu, but in fact a "watchpoint" is created.