Menu

Debugger

sit
2011-03-15
2013-04-09
  • sit

    sit - 2011-03-15

    Hi
    I am total beginner and your lessons out there are really wonderful.
    currently I am going through "using debugger lesson 2".
    I am using the same debugger tutorial file.

    I have put the break point at line number 158 (mylibrary class - main)

    158 public static void main(String args) {
    159 // create a new mylibrary
    160 MyLibrary testLibrary = new MyLibrary("Test Drive Library");
    161 Book b1 = new Book("War and Peace");
            b1.setAuthor("Tolstoy");
            Book b2 = new Book("Great Expectations");
            b2.setAuthor("Charles Dickens");

    let me come to the problem I am facing,
         when I press step over, it is not going to line number 161.
    It goes to line number 111  if (aBook.getPerson().getName(). and throws some error and the program terminates

    thanks in advance for your hep

     
  • sit

    sit - 2011-03-15

    few more details.
    I think the problem is because of not handling the null-pointer exception.

    when I run MyLibrary class,I get

    Exception in thread "main" java.lang.NullPointerException
    at org.debugger.tutorial.MyLibrary.getBooksForPerson(MyLibrary.java:111)
    at org.debugger.tutorial.MyLibrary.printStatus(MyLibrary.java:202)
    at org.debugger.tutorial.MyLibrary.main(MyLibrary.java:177)

     
  • sit

    sit - 2011-03-15

    I am struck.Please someone help me

     
  • Mark Dexter

    Mark Dexter - 2011-03-15

    Line 160 is executing the constructor for the MyLibrary class. If there is an error in this method, the debugger can't get to line 161. So you evidently have an error in your code. I would double-check that you imported the code correctly. Good luck. Mark

     
  • sit

    sit - 2011-03-17

    Hi Mark
    Thanks for your quick replay.I corrected the code.You are talking about the same null pointer exception at line no.111 on chapter 4.Its fine. But I am facing another problem on debugging and it is getting terminated.Can you please advise me on this.

    **<terminated, exit value: 0>C:\Program Files\Java\jre6\bin\javaw.exe (Mar 17, 2011 2:58:52 PM)   **

    after setting the breakpoint at my main(MyLibrary class), when I am trying to debug my program , it is getting terminated with the following messages

    org.debugger.tutorial.MyLibrary at localhost:49286  
        Thread  (Suspended (entry into method main in MyLibrary))  
            MyLibrary.main(String) line: 163  
    <terminated, exit value: 0>C:\Program Files\Java\jre6\bin\javaw.exe (Mar 17, 2011 2:58:52 PM)   

     

Log in to post a comment.