Difference between revisions of "Netbeans/C2/Netbeans-Debugger/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
Line 5: Line 5:
  
 
|-
 
|-
| 00.01
+
| 00:01
 
|Hii everyone.  
 
|Hii everyone.  
  
 
|-
 
|-
| 00.02
+
| 00:02
 
| Welcome to the tutorial on '''Netbeans Debugger. '''
 
| Welcome to the tutorial on '''Netbeans Debugger. '''
  
 
|-
 
|-
|00.06
+
|00:06
 
|If this is the first time you are using '''Netbeans''', please view the earlier tutorials on the '''Spoken Tutorial''' website.  
 
|If this is the first time you are using '''Netbeans''', please view the earlier tutorials on the '''Spoken Tutorial''' website.  
  
 
|-
 
|-
|00.14
+
|00:14
 
|For this demonstration, I am using the Linux Operating System Ubuntu v12.04,  
 
|For this demonstration, I am using the Linux Operating System Ubuntu v12.04,  
  
 
|-
 
|-
| 00.21
+
| 00:21
 
|and Netbeans IDE v7.1.1  
 
|and Netbeans IDE v7.1.1  
  
 
|-
 
|-
|00.26
+
|00:26
 
|We all know that '''debugging''' programs can be a rather painstaking task.  
 
|We all know that '''debugging''' programs can be a rather painstaking task.  
  
 
|-
 
|-
| 00.31
+
| 00:31
 
|Hence, knowing a '''debugging''' tool and being familiar with its features can help you save valuable time.  
 
|Hence, knowing a '''debugging''' tool and being familiar with its features can help you save valuable time.  
  
 
|-
 
|-
| 00.39
+
| 00:39
 
|This powerful '''debugging''' tool is very useful,  
 
|This powerful '''debugging''' tool is very useful,  
  
 
|-
 
|-
|00.42
+
|00:42
 
|especially when you have to code or test large programs.  
 
|especially when you have to code or test large programs.  
  
 
|-
 
|-
| 00.46
+
| 00:46
 
|In this tutorial we will learn some of the features that the '''Netbeans Debugger''' provides.  
 
|In this tutorial we will learn some of the features that the '''Netbeans Debugger''' provides.  
  
 
|-
 
|-
| 00.53
+
| 00:53
 
| This tutorial will acquaint you with
 
| This tutorial will acquaint you with
  
 
|-
 
|-
|00.55
+
|00:55
 
|the '''debugging''' window  
 
|the '''debugging''' window  
  
  
 
|-
 
|-
|00.58
+
|00:58
 
|configuring breakpoints  
 
|configuring breakpoints  
  
 
|-
 
|-
  
|01.00
+
|01:00
  
 
|evaluating expressions  or setting watches
 
|evaluating expressions  or setting watches
Line 67: Line 67:
 
|-
 
|-
  
|01.04
+
|01:04
 
|options for tracing the execution of your program  
 
|options for tracing the execution of your program  
  
Line 73: Line 73:
 
|-
 
|-
  
| 01.17
+
| 01:17
  
 
|and options to configure the '''debugger''' itself  
 
|and options to configure the '''debugger''' itself  
Line 80: Line 80:
 
|-
 
|-
  
|01.12
+
|01:12
  
 
|Now Let's get started and '''debug''' this sample code.  
 
|Now Let's get started and '''debug''' this sample code.  
Line 86: Line 86:
 
|-
 
|-
  
|01.17
+
|01:17
  
 
|I will switch to the Netbeans IDE  
 
|I will switch to the Netbeans IDE  
Line 93: Line 93:
 
|-
 
|-
  
|01.20
+
|01:20
  
 
|I have already created a Java Application, '''sampleDebug''' in my IDE for this demonstration.  
 
|I have already created a Java Application, '''sampleDebug''' in my IDE for this demonstration.  
 
|-
 
|-
  
|01.27
+
|01:27
  
 
|This is a small program that initializes three integer values a, b, and c.  
 
|This is a small program that initializes three integer values a, b, and c.  
Line 104: Line 104:
  
 
|-
 
|-
|01.35
+
|01:35
 
|Then it prints''' 'Hello World!' ''' and the value of 'a'.  
 
|Then it prints''' 'Hello World!' ''' and the value of 'a'.  
  
 
|-
 
|-
  
|01.40
+
|01:40
  
 
|It also creates a class object ''''SampleClass',''' which has a ''' 'value' ''' integer, as a private integer value.  
 
|It also creates a class object ''''SampleClass',''' which has a ''' 'value' ''' integer, as a private integer value.  
Line 115: Line 115:
 
|-
 
|-
  
|01.52
+
|01:52
  
 
|Then, it computes the value of ''' 'b' ''',  
 
|Then, it computes the value of ''' 'b' ''',  
Line 121: Line 121:
 
|-
 
|-
  
|01.55
+
|01:55
  
 
| and calls a function to compute the value of c,  
 
| and calls a function to compute the value of c,  
Line 128: Line 128:
 
|-
 
|-
  
| 02.00
+
| 02:00
  
 
|and prints the values of 'b' and 'c'.  
 
|and prints the values of 'b' and 'c'.  
Line 135: Line 135:
 
|-
 
|-
  
| 02.05
+
| 02:05
  
 
|To start with the '''debugging''', let us first set the breakpoint.  
 
|To start with the '''debugging''', let us first set the breakpoint.  
  
 
|-
 
|-
| 02.09
+
| 02:09
 
|To set a breakpoint, click on the line number.  
 
|To set a breakpoint, click on the line number.  
  
 
|-
 
|-
| 02.13
+
| 02:13
 
|I will set at this line which prints ''' Hello World!'''
 
|I will set at this line which prints ''' Hello World!'''
  
Line 150: Line 150:
  
 
|-
 
|-
| 02.18
+
| 02:18
 
|Notice that the line at which a breakpoint is set changes it's colour to pink and is marked by a small square against its line number.  
 
|Notice that the line at which a breakpoint is set changes it's colour to pink and is marked by a small square against its line number.  
  
 
|-
 
|-
| 02.28
+
| 02:28
 
|When you run the program in the '''debugging''' mode,  
 
|When you run the program in the '''debugging''' mode,  
  
 
|-
 
|-
| 02.31
+
| 02:31
 
|by clicking on the ''' Debug Project''' button in the toolbar,  
 
|by clicking on the ''' Debug Project''' button in the toolbar,  
  
 
|-
 
|-
|02.35
+
|02:35
 
| the execution of the program stops at the line at which the breakpoint is located.  
 
| the execution of the program stops at the line at which the breakpoint is located.  
  
 
|-
 
|-
|02.41
+
|02:41
 
|So far, 'a's value has been set.  
 
|So far, 'a's value has been set.  
  
 
|-
 
|-
|02.45
+
|02:45
 
| Hover on it to check it's value.  
 
| Hover on it to check it's value.  
  
  
 
|-
 
|-
|02.49
+
|02:49
 
|It indicates that it's value is 10.  
 
|It indicates that it's value is 10.  
  
  
 
|-
 
|-
| 02.52
+
| 02:52
 
|You can see that there are some additional windows below the workspace.  
 
|You can see that there are some additional windows below the workspace.  
  
 
|-
 
|-
| 02.59
+
| 02:59
 
|There is a 'Variables' window that shows a list of variables and their values.  
 
|There is a 'Variables' window that shows a list of variables and their values.  
  
Line 190: Line 190:
 
|-
 
|-
  
| 03.07
+
| 03:07
  
 
|So far, only the variable 'a' has been initialized.  
 
|So far, only the variable 'a' has been initialized.  
Line 197: Line 197:
 
|-
 
|-
  
|03.11
+
|03:11
  
 
|We can also look at the 'Output' window with the sample '''debug''' output.  
 
|We can also look at the 'Output' window with the sample '''debug''' output.  
Line 205: Line 205:
 
|-
 
|-
  
|03.17
+
|03:17
  
 
|There is no output yet.  
 
|There is no output yet.  
Line 212: Line 212:
 
|-
 
|-
  
| 03.19
+
| 03:19
  
 
|There is also a  ''' 'Debugger Console' '''' that says that the program hit a breakpoint on line 29 and has stopped there.  
 
|There is also a  ''' 'Debugger Console' '''' that says that the program hit a breakpoint on line 29 and has stopped there.  
Line 219: Line 219:
 
|-
 
|-
  
| 03.28
+
| 03:28
  
 
|There is also a ''''Breakpoints' ''' window that tells you that a breakpoint has been set on line number 29.  
 
|There is also a ''''Breakpoints' ''' window that tells you that a breakpoint has been set on line number 29.  
Line 226: Line 226:
 
|-
 
|-
  
| 03.36
+
| 03:36
  
 
|Before proceeding, let us see how to add a watch.  
 
|Before proceeding, let us see how to add a watch.  
Line 233: Line 233:
 
|-
 
|-
  
| 03.40
+
| 03:40
  
 
|For example, let us say I want to watch on the integer value  ''' 'aSample'. '''
 
|For example, let us say I want to watch on the integer value  ''' 'aSample'. '''
Line 240: Line 240:
 
|-
 
|-
  
| 03.48
+
| 03:48
  
 
|In the 'Variables' window below the workspace, I will double-click on  the '''Enter new Watch''' option and enter the name of the variable  ''' 'aSample.value'. '''
 
|In the 'Variables' window below the workspace, I will double-click on  the '''Enter new Watch''' option and enter the name of the variable  ''' 'aSample.value'. '''
Line 247: Line 247:
 
|-
 
|-
  
| 04.02
+
| 04:02
 
|Click on '''OK. '''
 
|Click on '''OK. '''
  
Line 253: Line 253:
  
 
|-
 
|-
| 04.06
+
| 04:06
 
|So far ''' 'aSample' ''' has not been created so it says it does not know the value.  
 
|So far ''' 'aSample' ''' has not been created so it says it does not know the value.  
  
Line 259: Line 259:
 
|-
 
|-
  
| 04.12
+
| 04:12
 
|Once it executes the line we'll know what the variable contains.  
 
|Once it executes the line we'll know what the variable contains.  
  
Line 267: Line 267:
 
|-
 
|-
  
| 04.16
+
| 04:16
  
 
|In a similar way you can also watch and evaluate expressions.  
 
|In a similar way you can also watch and evaluate expressions.  
Line 274: Line 274:
 
|-
 
|-
  
| 04.21
+
| 04:21
  
 
|  Here I'm checking for b=a+10.
 
|  Here I'm checking for b=a+10.
Line 281: Line 281:
 
|-
 
|-
  
| 04.25
+
| 04:25
 
   
 
   
 
|What if I wanted to know what a-4 is.  
 
|What if I wanted to know what a-4 is.  
  
 
|-
 
|-
| 04.29
+
| 04:29
 
|So let me go to the '''Debug''' menu in the menu bar, and select '''Evaluate expression''' option.  
 
|So let me go to the '''Debug''' menu in the menu bar, and select '''Evaluate expression''' option.  
 
|-
 
|-
  
| 04.37
+
| 04:37
 
   
 
   
 
|The ''' 'Evaluate Code' ''' window appears in the workspace.  
 
|The ''' 'Evaluate Code' ''' window appears in the workspace.  
  
 
|-
 
|-
| 04.41
+
| 04:41
 
|Here I will enter the expression ''' 'a-4'.'''  
 
|Here I will enter the expression ''' 'a-4'.'''  
  
 
|-
 
|-
| 04.45
+
| 04:45
 
|Click on the '''Evaluate Expression button''' here, and in the Variable window, it says ''' 'a-4' '''s value is 6.  
 
|Click on the '''Evaluate Expression button''' here, and in the Variable window, it says ''' 'a-4' '''s value is 6.  
  
 
|-
 
|-
  
| 04.56
+
| 04:56
  
 
|Let us now proceed and execute this single line of code.  
 
|Let us now proceed and execute this single line of code.  
Line 310: Line 310:
 
|-
 
|-
  
| 05.00
+
| 05:00
  
 
|To do that, choose the '''Step-Over''' button from the toolbar.  
 
|To do that, choose the '''Step-Over''' button from the toolbar.  
Line 317: Line 317:
 
|-
 
|-
  
| 05.06
+
| 05:06
  
 
|That should execute only that 1 single line  of the code to print ''' “Hello World”.'''  
 
|That should execute only that 1 single line  of the code to print ''' “Hello World”.'''  
Line 323: Line 323:
 
|-
 
|-
  
| 05.12
+
| 05:12
  
 
| To see the output, go to the output window and choose the '''sampleDebug''' output window
 
| To see the output, go to the output window and choose the '''sampleDebug''' output window
Line 330: Line 330:
 
|-
 
|-
  
| 05.17
+
| 05:17
  
 
| That says, '''Hello World! a is 10. '''
 
| That says, '''Hello World! a is 10. '''
Line 337: Line 337:
 
|-
 
|-
  
| 05.22
+
| 05:22
  
 
|The program has now stopped at the line to create a '''SampleClass''' object.  
 
|The program has now stopped at the line to create a '''SampleClass''' object.  
Line 343: Line 343:
 
|-
 
|-
  
| 05.28
+
| 05:28
  
 
|Now, I want to go into the constructor of the ''' SampleClass.'''  
 
|Now, I want to go into the constructor of the ''' SampleClass.'''  
  
 
|-
 
|-
| 05.32
+
| 05:32
 
|To that I can choose the ''' Step Into''' option from the toolbar.  
 
|To that I can choose the ''' Step Into''' option from the toolbar.  
  
Line 354: Line 354:
 
|-
 
|-
  
| 05.41
+
| 05:41
  
 
|Then I can choose ''' Step Over''' and see that the value came inside the constructor call is now set to 10.  
 
|Then I can choose ''' Step Over''' and see that the value came inside the constructor call is now set to 10.  
Line 360: Line 360:
 
|-
 
|-
  
| 05.51
+
| 05:51
  
 
| You can also check that by hovering on the variable.  
 
| You can also check that by hovering on the variable.  
Line 366: Line 366:
 
|-
 
|-
  
| 05.55
+
| 05:55
  
 
|When I Step Over again, we can see that '''this.variable''' is also set to 10.  
 
|When I Step Over again, we can see that '''this.variable''' is also set to 10.  
Line 373: Line 373:
 
|-
 
|-
  
| 06.03
+
| 06:03
  
 
|To get out of this function I can either choose '''Continue, Step Over or Step Out.'''  
 
|To get out of this function I can either choose '''Continue, Step Over or Step Out.'''  
Line 380: Line 380:
 
|-
 
|-
  
| 06.11
+
| 06:11
  
 
|Let me choose '''Step-Out''' to come out of the method.  
 
|Let me choose '''Step-Out''' to come out of the method.  
Line 386: Line 386:
 
|-
 
|-
  
| 06.14
+
| 06:14
  
 
|And now I'm back to where the function call was made.  
 
|And now I'm back to where the function call was made.  
Line 392: Line 392:
 
|-
 
|-
  
| 06.19
+
| 06:19
  
 
|When I say '''Step-Over''' again, you will notice that '''aSample.value''' is now set to10.   
 
|When I say '''Step-Over''' again, you will notice that '''aSample.value''' is now set to10.   
  
 
|-
 
|-
| 06.27
+
| 06:27
 
|This is what we were watching for.  
 
|This is what we were watching for.  
  
 
|-
 
|-
  
| 06.30
+
| 06:30
  
 
| Apart from Breakpoints and StepOvers, you can also stop the execution of the program at the line of the cursor.  
 
| Apart from Breakpoints and StepOvers, you can also stop the execution of the program at the line of the cursor.  
  
 
|-
 
|-
| 06.38
+
| 06:38
 
|For example, let me go into the function here and set the cursor to be on this line which says d=b-5; .  
 
|For example, let me go into the function here and set the cursor to be on this line which says d=b-5; .  
  
Line 413: Line 413:
 
|-
 
|-
  
| 06.49
+
| 06:49
  
 
|Now from the toolbar, choose the '''Run To Cursor''' option.  
 
|Now from the toolbar, choose the '''Run To Cursor''' option.  
Line 419: Line 419:
 
|-
 
|-
  
| 06.54
+
| 06:54
  
 
|You will notice that the execution of the program gets into the function and stops at the line where the cursor is located.  
 
|You will notice that the execution of the program gets into the function and stops at the line where the cursor is located.  
Line 425: Line 425:
 
|-
 
|-
  
| 07.05
+
| 07:05
  
 
|You can see that it has computed the value of b, as 20.  
 
|You can see that it has computed the value of b, as 20.  
Line 431: Line 431:
 
|-
 
|-
  
| 07.10
+
| 07:10
  
 
|And inside the variable window, it has set 'b' to be 20.  
 
|And inside the variable window, it has set 'b' to be 20.  
Line 437: Line 437:
 
|-
 
|-
  
| 07.14
+
| 07:14
  
 
|Now, I can choose '''Step Over''' again and d's value also gets initialized and becomes 15.  
 
|Now, I can choose '''Step Over''' again and d's value also gets initialized and becomes 15.  
Line 443: Line 443:
 
|-
 
|-
  
| 07.23
+
| 07:23
  
 
|Now, I can either choose to return or completely finish the execution of the program.  
 
|Now, I can either choose to return or completely finish the execution of the program.  
Line 449: Line 449:
 
|-
 
|-
  
| 07.29
+
| 07:29
  
 
|Let me choose '''Step Out''' and come back to the function call.  
 
|Let me choose '''Step Out''' and come back to the function call.  
Line 457: Line 457:
 
|-
 
|-
  
| 07.36
+
| 07:36
  
 
|When you hover on the '''getC() '''function, you'll notice that the function has returned a value of 15.  
 
|When you hover on the '''getC() '''function, you'll notice that the function has returned a value of 15.  
Line 463: Line 463:
 
|-
 
|-
  
| 07.43
+
| 07:43
  
 
| The variable 'c' has not yet been assigned that value.  
 
| The variable 'c' has not yet been assigned that value.  
Line 469: Line 469:
 
|-
 
|-
  
| 07.47
+
| 07:47
  
 
|So, when we '''Step Over''' and execute that line, 'c' will get a value of 15.  
 
|So, when we '''Step Over''' and execute that line, 'c' will get a value of 15.  
Line 477: Line 477:
 
|-
 
|-
  
| 07.55
+
| 07:55
  
 
|We can now check it in the variable window or hover on the variable to check it's value.  
 
|We can now check it in the variable window or hover on the variable to check it's value.  
Line 483: Line 483:
 
|-
 
|-
  
| 08.03
+
| 08:03
  
 
|Now if you want to stop the '''debugging''' session, you can choose the '''Finish Debugger Session''' option from the toolbar.  
 
|Now if you want to stop the '''debugging''' session, you can choose the '''Finish Debugger Session''' option from the toolbar.  
Line 489: Line 489:
 
|-
 
|-
  
| 08.12
+
| 08:12
  
 
|If you want to continue the execution to the next breakpoint you can choose the '''Continue''' option.  
 
|If you want to continue the execution to the next breakpoint you can choose the '''Continue''' option.  
Line 495: Line 495:
 
|-
 
|-
  
| 08.19
+
| 08:19
  
 
|Once you finish, you can also choose the '''Continue option''' to complete the execution of the remaining program.  
 
|Once you finish, you can also choose the '''Continue option''' to complete the execution of the remaining program.  
Line 501: Line 501:
 
|-
 
|-
  
| 08.25
+
| 08:25
  
 
|Let me choose '''Continue''' here.  
 
|Let me choose '''Continue''' here.  
Line 507: Line 507:
 
|-
 
|-
  
| 08.27
+
| 08:27
  
 
|In the Output window, it shows me the output as: ''' b '''is 20 and '''c''' is 15.  
 
|In the Output window, it shows me the output as: ''' b '''is 20 and '''c''' is 15.  
Line 513: Line 513:
 
|-
 
|-
  
| 08.34
+
| 08:34
  
 
|Now, this was a quick overview of the options of '''debugging''' on '''netbeans. '''
 
|Now, this was a quick overview of the options of '''debugging''' on '''netbeans. '''
Line 520: Line 520:
 
|-
 
|-
  
| 08.39
+
| 08:39
  
 
|If you want any advanced feature settings, you can -  
 
|If you want any advanced feature settings, you can -  
Line 528: Line 528:
 
|-
 
|-
  
| 08.42
+
| 08:42
  
 
|Go to '''Tools''' menu, click on '''Options''', go to '''Miscellaneous''' option, click on the '''Java Debugger''' tab.  
 
|Go to '''Tools''' menu, click on '''Options''', go to '''Miscellaneous''' option, click on the '''Java Debugger''' tab.  
Line 536: Line 536:
 
|-
 
|-
  
| 08.53
+
| 08:53
 
   
 
   
 
|Here you can change settings for multi-threaded program breakpoint options.
 
|Here you can change settings for multi-threaded program breakpoint options.
 
|-
 
|-
  
| 08.59
+
| 08:59
 
   
 
   
 
|Or have filters to decide on which methods you would want to step in.  
 
|Or have filters to decide on which methods you would want to step in.  
  
 
|-
 
|-
| 09.07
+
| 09:07
 
|Now to the assignment.
 
|Now to the assignment.
  
 
|-
 
|-
| 09.09
+
| 09:09
 
|As an assignment, take any of your programs, excellent if it has already errors.
 
|As an assignment, take any of your programs, excellent if it has already errors.
  
 
|-
 
|-
| 09.16
+
| 09:16
 
|If not, introduce some errors with the logic or algorithm.  
 
|If not, introduce some errors with the logic or algorithm.  
  
 
|-
 
|-
| 09.20
+
| 09:20
 
|Set breakpoints in the code. Usually, you would set a break at the calling point of a function which you suspect has the error.  
 
|Set breakpoints in the code. Usually, you would set a break at the calling point of a function which you suspect has the error.  
  
 
|-
 
|-
  
| 09.29
+
| 09:29
  
 
|Use '''Step-Into''' to go into the function.  
 
|Use '''Step-Into''' to go into the function.  
Line 569: Line 569:
 
|-
 
|-
  
| 09.32
+
| 09:32
  
 
|Use '''Step-Overs''' to execute the lines and make sure to inspect the values of variables in the variable window.  
 
|Use '''Step-Overs''' to execute the lines and make sure to inspect the values of variables in the variable window.  
Line 576: Line 576:
 
|-
 
|-
  
| 09.41
+
| 09:41
  
 
|Add some watches to help you identify and correct the error.  
 
|Add some watches to help you identify and correct the error.  
Line 583: Line 583:
 
|-
 
|-
  
| 09.45
+
| 09:45
  
 
|Step-Out of the method.  
 
|Step-Out of the method.  
Line 589: Line 589:
 
|-
 
|-
  
| 09.48
+
| 09:48
  
 
|Continue till you reach the next breakpoint.  
 
|Continue till you reach the next breakpoint.  
Line 595: Line 595:
 
|-
 
|-
  
| 09.51
+
| 09:51
  
 
|And finally, Finish the '''debugger''' session and Run your application.  
 
|And finally, Finish the '''debugger''' session and Run your application.  
 
|-
 
|-
  
| 09.57
+
| 09:57
  
 
|In this tutorial, we became familiar with the '''netbeans debugger. '''
 
|In this tutorial, we became familiar with the '''netbeans debugger. '''
Line 606: Line 606:
 
|-
 
|-
  
| 10.02
+
| 10:02
  
 
|We saw how to set breakpoints and watches.  
 
|We saw how to set breakpoints and watches.  
Line 612: Line 612:
 
|-
 
|-
  
| 10.06
+
| 10:06
  
 
|Add expressions which we want to evaluate, while the code is running.  
 
|Add expressions which we want to evaluate, while the code is running.  
Line 618: Line 618:
 
|-
 
|-
  
| 10.11
+
| 10:11
  
 
|Trace execution of a program with '''Step-Into, Step-Over, Step-Out and Run-to-Cursor''' options.  
 
|Trace execution of a program with '''Step-Into, Step-Over, Step-Out and Run-to-Cursor''' options.  
Line 624: Line 624:
 
|-
 
|-
  
| 10.19
+
| 10:19
  
 
|Also saw how to configure the '''debugger''' for advanced '''debugging.'''  
 
|Also saw how to configure the '''debugger''' for advanced '''debugging.'''  
Line 630: Line 630:
 
|-
 
|-
  
|10.24
+
|10:24
  
 
|Hope this tutorial saves you a lot of time in your testing and '''debugging''' tasks.  
 
|Hope this tutorial saves you a lot of time in your testing and '''debugging''' tasks.  
Line 637: Line 637:
 
|-
 
|-
  
|10.30
+
|10:30
  
 
|Watch the video available at the link shown on the screen.  
 
|Watch the video available at the link shown on the screen.  
Line 643: Line 643:
 
|-
 
|-
  
| 10.33
+
| 10:33
  
 
|It summarizes the Spoken Tutorial project.  
 
|It summarizes the Spoken Tutorial project.  
Line 649: Line 649:
 
|-
 
|-
  
|10.36
+
|10:36
  
 
|If you do not have good bandwidth, you can download and watch it
 
|If you do not have good bandwidth, you can download and watch it
Line 655: Line 655:
 
|-
 
|-
  
| 10.41
+
| 10:41
  
 
|The Spoken Tutorial project team conduct workshops using Spoken Tutorials.  
 
|The Spoken Tutorial project team conduct workshops using Spoken Tutorials.  
Line 662: Line 662:
 
|-
 
|-
  
| 10.46
+
| 10:46
  
 
|Gives certificates to those who pass an online test.  
 
|Gives certificates to those who pass an online test.  
Line 669: Line 669:
 
|-
 
|-
  
| 10.49
+
| 10:49
  
 
|For more details contact contact@spoken-tutorial.org
 
|For more details contact contact@spoken-tutorial.org
Line 676: Line 676:
 
|-
 
|-
  
| 10.55
+
| 10:55
  
 
|Spoken Tutorial Project is a part of the Talk to a Teacher Project
 
|Spoken Tutorial Project is a part of the Talk to a Teacher Project
Line 682: Line 682:
 
|-
 
|-
  
| 10.59
+
| 10:59
  
 
| It is Supported by the National Mission on education through ICT, MHRD, Government  of India
 
| It is Supported by the National Mission on education through ICT, MHRD, Government  of India
Line 688: Line 688:
 
|-
 
|-
  
| 11.05
+
| 11:05
  
 
|More information on this mission is available at spoken-tutorial.org/NMEICT-Intro
 
|More information on this mission is available at spoken-tutorial.org/NMEICT-Intro
Line 694: Line 694:
 
|-
 
|-
  
| 11.14
+
| 11:14
  
 
|This tutorial has been  contributed by  IT for Change  
 
|This tutorial has been  contributed by  IT for Change  
Line 701: Line 701:
 
|-
 
|-
  
| 11.18
+
| 11:18
  
 
|Thank you for joining us.
 
|Thank you for joining us.

Revision as of 12:14, 10 July 2014

Time Narration
00:01 Hii everyone.
00:02 Welcome to the tutorial on Netbeans Debugger.
00:06 If this is the first time you are using Netbeans, please view the earlier tutorials on the Spoken Tutorial website.
00:14 For this demonstration, I am using the Linux Operating System Ubuntu v12.04,
00:21 and Netbeans IDE v7.1.1
00:26 We all know that debugging programs can be a rather painstaking task.
00:31 Hence, knowing a debugging tool and being familiar with its features can help you save valuable time.
00:39 This powerful debugging tool is very useful,
00:42 especially when you have to code or test large programs.
00:46 In this tutorial we will learn some of the features that the Netbeans Debugger provides.
00:53 This tutorial will acquaint you with
00:55 the debugging window


00:58 configuring breakpoints
01:00 evaluating expressions or setting watches


01:04 options for tracing the execution of your program


01:17 and options to configure the debugger itself


01:12 Now Let's get started and debug this sample code.
01:17 I will switch to the Netbeans IDE


01:20 I have already created a Java Application, sampleDebug in my IDE for this demonstration.
01:27 This is a small program that initializes three integer values a, b, and c.


01:35 Then it prints 'Hello World!' and the value of 'a'.
01:40 It also creates a class object 'SampleClass', which has a 'value' integer, as a private integer value.
01:52 Then, it computes the value of 'b' ,
01:55 and calls a function to compute the value of c,


02:00 and prints the values of 'b' and 'c'.


02:05 To start with the debugging, let us first set the breakpoint.
02:09 To set a breakpoint, click on the line number.
02:13 I will set at this line which prints Hello World!


02:18 Notice that the line at which a breakpoint is set changes it's colour to pink and is marked by a small square against its line number.
02:28 When you run the program in the debugging mode,
02:31 by clicking on the Debug Project button in the toolbar,
02:35 the execution of the program stops at the line at which the breakpoint is located.
02:41 So far, 'a's value has been set.
02:45 Hover on it to check it's value.


02:49 It indicates that it's value is 10.


02:52 You can see that there are some additional windows below the workspace.
02:59 There is a 'Variables' window that shows a list of variables and their values.


03:07 So far, only the variable 'a' has been initialized.


03:11 We can also look at the 'Output' window with the sample debug output.


03:17 There is no output yet.


03:19 There is also a 'Debugger Console' ' that says that the program hit a breakpoint on line 29 and has stopped there.


03:28 There is also a 'Breakpoints' window that tells you that a breakpoint has been set on line number 29.


03:36 Before proceeding, let us see how to add a watch.


03:40 For example, let us say I want to watch on the integer value 'aSample'.


03:48 In the 'Variables' window below the workspace, I will double-click on the Enter new Watch option and enter the name of the variable 'aSample.value'.


04:02 Click on OK.


04:06 So far 'aSample' has not been created so it says it does not know the value.


04:12 Once it executes the line we'll know what the variable contains.



04:16 In a similar way you can also watch and evaluate expressions.


04:21 Here I'm checking for b=a+10.


04:25 What if I wanted to know what a-4 is.
04:29 So let me go to the Debug menu in the menu bar, and select Evaluate expression option.
04:37 The 'Evaluate Code' window appears in the workspace.
04:41 Here I will enter the expression 'a-4'.
04:45 Click on the Evaluate Expression button here, and in the Variable window, it says 'a-4' s value is 6.
04:56 Let us now proceed and execute this single line of code.
05:00 To do that, choose the Step-Over button from the toolbar.


05:06 That should execute only that 1 single line of the code to print “Hello World”.
05:12 To see the output, go to the output window and choose the sampleDebug output window


05:17 That says, Hello World! a is 10.


05:22 The program has now stopped at the line to create a SampleClass object.
05:28 Now, I want to go into the constructor of the SampleClass.
05:32 To that I can choose the Step Into option from the toolbar.


05:41 Then I can choose Step Over and see that the value came inside the constructor call is now set to 10.
05:51 You can also check that by hovering on the variable.
05:55 When I Step Over again, we can see that this.variable is also set to 10.


06:03 To get out of this function I can either choose Continue, Step Over or Step Out.


06:11 Let me choose Step-Out to come out of the method.
06:14 And now I'm back to where the function call was made.
06:19 When I say Step-Over again, you will notice that aSample.value is now set to10.
06:27 This is what we were watching for.
06:30 Apart from Breakpoints and StepOvers, you can also stop the execution of the program at the line of the cursor.
06:38 For example, let me go into the function here and set the cursor to be on this line which says d=b-5; .


06:49 Now from the toolbar, choose the Run To Cursor option.
06:54 You will notice that the execution of the program gets into the function and stops at the line where the cursor is located.
07:05 You can see that it has computed the value of b, as 20.
07:10 And inside the variable window, it has set 'b' to be 20.
07:14 Now, I can choose Step Over again and d's value also gets initialized and becomes 15.
07:23 Now, I can either choose to return or completely finish the execution of the program.
07:29 Let me choose Step Out and come back to the function call.


07:36 When you hover on the getC() function, you'll notice that the function has returned a value of 15.
07:43 The variable 'c' has not yet been assigned that value.
07:47 So, when we Step Over and execute that line, 'c' will get a value of 15.


07:55 We can now check it in the variable window or hover on the variable to check it's value.
08:03 Now if you want to stop the debugging session, you can choose the Finish Debugger Session option from the toolbar.
08:12 If you want to continue the execution to the next breakpoint you can choose the Continue option.
08:19 Once you finish, you can also choose the Continue option to complete the execution of the remaining program.
08:25 Let me choose Continue here.
08:27 In the Output window, it shows me the output as: b is 20 and c is 15.
08:34 Now, this was a quick overview of the options of debugging on netbeans.


08:39 If you want any advanced feature settings, you can -


08:42 Go to Tools menu, click on Options, go to Miscellaneous option, click on the Java Debugger tab.


08:53 Here you can change settings for multi-threaded program breakpoint options.
08:59 Or have filters to decide on which methods you would want to step in.
09:07 Now to the assignment.
09:09 As an assignment, take any of your programs, excellent if it has already errors.
09:16 If not, introduce some errors with the logic or algorithm.
09:20 Set breakpoints in the code. Usually, you would set a break at the calling point of a function which you suspect has the error.
09:29 Use Step-Into to go into the function.
09:32 Use Step-Overs to execute the lines and make sure to inspect the values of variables in the variable window.


09:41 Add some watches to help you identify and correct the error.


09:45 Step-Out of the method.
09:48 Continue till you reach the next breakpoint.
09:51 And finally, Finish the debugger session and Run your application.
09:57 In this tutorial, we became familiar with the netbeans debugger.
10:02 We saw how to set breakpoints and watches.
10:06 Add expressions which we want to evaluate, while the code is running.
10:11 Trace execution of a program with Step-Into, Step-Over, Step-Out and Run-to-Cursor options.
10:19 Also saw how to configure the debugger for advanced debugging.
10:24 Hope this tutorial saves you a lot of time in your testing and debugging tasks.


10:30 Watch the video available at the link shown on the screen.
10:33 It summarizes the Spoken Tutorial project.
10:36 If you do not have good bandwidth, you can download and watch it
10:41 The Spoken Tutorial project team conduct workshops using Spoken Tutorials.


10:46 Gives certificates to those who pass an online test.


10:49 For more details contact contact@spoken-tutorial.org


10:55 Spoken Tutorial Project is a part of the Talk to a Teacher Project
10:59 It is Supported by the National Mission on education through ICT, MHRD, Government of India
11:05 More information on this mission is available at spoken-tutorial.org/NMEICT-Intro
11:14 This tutorial has been contributed by IT for Change


11:18 Thank you for joining us.

Contributors and Content Editors

PoojaMoolya, Pratik kamble, Sandhya.np14