Difference between revisions of "Java/C2/Errors-and-Debugging-in-Eclipse/English-timed"

From Script | Spoken-Tutorial
Jump to: navigation, search
 
(2 intermediate revisions by one other user not shown)
Line 4: Line 4:
 
|-
 
|-
 
| 00:01
 
| 00:01
|  Welcome to the  tutorial on '''Errors and Debugging using Eclipse.'''
+
|  Welcome to the  tutorial on '''Errors and Debugging''' using '''Eclipse.'''
  
 
|-
 
|-
Line 12: Line 12:
 
|-
 
|-
 
| 00:10
 
| 00:10
|what are the possible errors while writing a simple '''Java '''program,  
+
|what are the possible '''error'''s while writing a simple '''Java '''program,  
  
 
|-
 
|-
 
| 00:14
 
| 00:14
|how to identify those errors and rectify them using '''eclipse'''.
+
|how to identify those '''error'''s and rectify them using '''eclipse'''.
 
   
 
   
 
|-
 
|-
 
|  00:20
 
|  00:20
| For this tutorial we are using  
+
| For this tutorial, we are using '''Ubuntu 11.10''' and '''Eclipse 3.7'''.
 
+
'''Ubuntu 11.10''' and
+
 
+
'''Eclipse 3.7'''.
+
  
 
|-
 
|-
Line 32: Line 28:
 
|-
 
|-
 
| 00:30
 
| 00:30
|how to create and run a '''Java Program '''in '''Eclipse.'''
+
|how to create and '''run''' a Java Program in '''Eclipse.'''
  
 
|-
 
|-
 
| 00:33
 
| 00:33
|If not, for relevant tutorial please visit our website as shown. [http://spoken-tuitorial.org]
+
|If not, for relevant tutorial, please visit our website as shown. [http://spoken-tuitorial.org]
  
 
|-
 
|-
Line 44: Line 40:
 
|-
 
|-
 
| 00:45
 
| 00:45
|* Missing semicolon(;)
+
| Missing semicolon(;)
 
|-
 
|-
 
| 00:47
 
| 00:47
|* Missing double quotes(" ") around the message  
+
| Missing double quotes(" ") around the message  
 
|-
 
|-
 
| 00:50
 
| 00:50
|* Mis-match of filename and classname and
+
| Mis-match of 'file name' and 'class name' and
 
|-
 
|-
 
| 00:52
 
| 00:52
|* Typing the print statement in lower-case.
+
| Typing the print statement in lower-case.
  
 
|-
 
|-
Line 61: Line 57:
 
|-
 
|-
 
|  01:04
 
|  01:04
|   Here we have the '''Eclipse IDE''' and the project used for the ''' HelloWorld''' tutorial.   
+
| Here we have the '''Eclipse IDE''' and the project used for the ''' HelloWorld''' tutorial.   
  
 
|-
 
|-
Line 81: Line 77:
 
|-
 
|-
 
| 02:44
 
| 02:44
|   The list of errors is displayed by hovering the mouse over the '''cross mark.'''
+
| The list of errors is displayed by hovering the mouse over the cross mark.
  
 
|-
 
|-
 
|  02:51
 
|  02:51
| The first error displayed is: '''syntax error, insert  semi-colon to complete block statements'''.  
+
|The first error displayed is: '''syntax error, insert  semi-colon to complete block statements'''.  
  
 
|-
 
|-
Line 101: Line 97:
 
|-
 
|-
 
|  03:16
 
|  03:16
| Notice that once we add the semi-colon and save the file, the first error is gone.
+
| Notice that once we add the semicolon and save the file, the first error is gone.
 
   
 
   
 
|-
 
|-
Line 113: Line 109:
 
|-
 
|-
 
|  03:41
 
|  03:41
|  Let us add double quotes before and after the message.   
+
|  Let us add ''double quotes'' before and after the message.   
  
 
|-
 
|-
 
| 03:55
 
| 03:55
|''' Ctrl s'''  to Save. We see that the red cross mark is gone and the program is error free. So, let us '''run''' the program and see what happens.
+
|''' Ctrl s'''  to '''Save'''. We see that the red-cross mark is gone and the program is error free. So, let us '''run''' the program and see what happens.
  
 
|-
 
|-
 
|  04:10
 
|  04:10
|  '''Run as''' > '''Java applications'''  
+
|  '''Run as''' > '''Java application'''  
 
   
 
   
 
|-
 
|-
Line 133: Line 129:
 
|-
 
|-
 
| 04:25
 
| 04:25
|It happens due to a mismatch of '''file name''' and '''class name.'''
+
|It happens due to a mismatch of the '''file name''' and '''class name.'''
  
 
|-
 
|-
 
| 04:29
 
| 04:29
|It does not  happens usually on '''Eclipse.'''
+
|It does not  happen usually on '''Eclipse.'''
  
 
|-
 
|-
 
| 04:31
 
| 04:31
|This is because we use the '''New Class wizard''' to create a file and '''eclipse'''
+
|This is because we use the '''New Class''' wizard to create a file and '''eclipse'''
  
 
|-
 
|-
Line 149: Line 145:
 
|-
 
|-
 
| 04:41
 
| 04:41
|  But if we create a '''Java file''' outside of '''Eclipse''' and add it to a project, there is a chance of the error.  
+
|  But, if we create a Java file outside of '''Eclipse''' and add it to a project, there is a chance of the error.  
  
 
|-
 
|-
 
| 04:47
 
| 04:47
|So let us stimulate the error by changing  the '''class name'''.
+
|So, let us stimulate the error by changing  the '''class name'''.
  
 
|-
 
|-
Line 165: Line 161:
 
|-
 
|-
 
|05:14
 
|05:14
| And error message reads '''The public type errorfree must be defined in its own file'''.
+
| And error message reads: '''The public type errorfree must be defined in its own file'''.
 
   
 
   
 
|-
 
|-
 
|05:20
 
|05:20
|Also notice that the word '''errorfree'''is ''' underlined in red colour.
+
|Also notice that the word '''errorfree''' is underlined in red colour.
 
    
 
    
 
|-
 
|-
Line 177: Line 173:
 
|-
 
|-
 
| 05:35
 
| 05:35
|  The first one is '''Rename compilation unit to errorfree java'''
+
|  The first one is '''Rename compilation unit to errorfree java'''.
 
|-
 
|-
 
| 05:39
 
| 05:39
Line 183: Line 179:
 
|-
 
|-
 
|  05:43
 
|  05:43
|The fix that we are looking for is the second one. And we see that once you rename the file,the '''class''' back to 'ErrorFree', the error here is missing.
+
|The fix that we are looking for is the second one. And we see that once you rename the file, the '''class''' back to 'ErrorFree', the error here is missing.
  
 
|-
 
|-
Line 199: Line 195:
 
|-
 
|-
 
|  06:18
 
|  06:18
| and error message reads  '''system cannot be resolved.'''
+
| and error message reads: '''system cannot be resolved.'''
  
 
|-
 
|-
Line 214: Line 210:
 
|-
 
|-
 
| 06:39
 
| 06:39
|There are '''11 fixes''', out of these the fix that we are looking for is the eighth option:
+
|There are '''11 fixes'''. Out of these, the fix that we are looking for is the eighth option:
  
 
|-
 
|-
 
|  06:48
 
|  06:48
|'''Change to 'System' (java.lang)'''
+
|'''Change to 'System' (java.lang)'''.
  
 
|-
 
|-
 
|  06:58
 
|  06:58
|You can see that once we change it to capital 'S' the error is missing.
+
|You can see that once we change it to capital 'S', the error is missing.
 
|-
 
|-
 
|  07:06
 
|  07:06
|  Here is  how you identify errors in Java using '''eclipse''' and rectify them.   
+
|  Here is  how you identify errors in Java, using '''eclipse''', and rectify them.   
 
|-
 
|-
 
|  07:15  
 
|  07:15  
Line 258: Line 254:
 
|-
 
|-
 
|  07:53
 
|  07:53
|  The Spoken Tutorial Team conducts workshops using '''spoken tutorials'''.
+
|  The Spoken Tutorial Team conducts workshops using spoken tutorials.
  
 
|-
 
|-
Line 266: Line 262:
 
|-
 
|-
 
| 08:07
 
| 08:07
'''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.
  
 
|-
 
|-
 
| 08:11
 
| 08:11
|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.
  
 
|-
 
|-
 
| 08:17
 
| 08:17
|More information on this Mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''
+
|More information on this mission is available at '''spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro'''
  
 
|-
 
|-

Latest revision as of 12:51, 28 March 2017

Time Narration
00:01 Welcome to the tutorial on Errors and Debugging using Eclipse.
00:07 In this tutorial, we are going to learn:
00:10 what are the possible errors while writing a simple Java program,
00:14 how to identify those errors and rectify them using eclipse.
00:20 For this tutorial, we are using Ubuntu 11.10 and Eclipse 3.7.
00:27 To follow this tutorial, you must know
00:30 how to create and run a Java Program in Eclipse.
00:33 If not, for relevant tutorial, please visit our website as shown. [1]
00:41 In a simple Java program, the typical errors could be:
00:45 Missing semicolon(;)
00:47 Missing double quotes(" ") around the message
00:50 Mis-match of 'file name' and 'class name' and
00:52 Typing the print statement in lower-case.
00:55 We shall write a program and then make each of these errors and see what happens in Eclipse.
01:04 Here we have the Eclipse IDE and the project used for the HelloWorld tutorial.
01:11 We shall create a new class in the project and use it. New Class. Let us name the class ErrorFree and select methods stubs public static void main.
01:37 Let us minimize the package explorer. Remove the comments and add the print statement with a few errors.
02:23 In Eclipse, the line which has the error will be indicated with a red cross mark on the left margin.
02:35 In this case, the System.out.println line has an error and hence there is a red cross mark on the left.
02:44 The list of errors is displayed by hovering the mouse over the cross mark.
02:51 The first error displayed is: syntax error, insert semi-colon to complete block statements.
02:58 This is because we have to end every statement of a program with a semicolon.
03:03 So, let us insert semicolon at the end of the statement.
03:08 Save the file with Ctrl s.
03:16 Notice that once we add the semicolon and save the file, the first error is gone.
03:21 There is only one error now which says: Helloworld cannot be resolved to a variable which means to display any message on the console the message has to be included in double quotes.
03:37 Without the quotes, Java thinks that HelloWorld is the name of a variable.
03:41 Let us add double quotes before and after the message.
03:55 Ctrl s to Save. We see that the red-cross mark is gone and the program is error free. So, let us run the program and see what happens.
04:10 Run as > Java application
04:15 We see that the message has been printed on the console.
04:22 Let us look at the next error.
04:25 It happens due to a mismatch of the file name and class name.
04:29 It does not happen usually on Eclipse.
04:31 This is because we use the New Class wizard to create a file and eclipse
04:39 creates a file automatically.
04:41 But, if we create a Java file outside of Eclipse and add it to a project, there is a chance of the error.
04:47 So, let us stimulate the error by changing the class name.
04:59 Since Java is case sensitive, now the class name and file name do not match .
05:09 Notice that there is a red cross mark on the left margin.
05:14 And error message reads: The public type errorfree must be defined in its own file.
05:20 Also notice that the word errorfree is underlined in red colour.
05:29 Eclipse offers intelligent fixes and we have 2 fixes available here.
05:35 The first one is Rename compilation unit to errorfree java.
05:39 The second one is Rename the type to errorfree.
05:43 The fix that we are looking for is the second one. And we see that once you rename the file, the class back to 'ErrorFree', the error here is missing.
06:03 The next error happens due to typing mistakes in the print statement.
06:09 Let us replace the capital S with a small s.
06:15 We notice that there is the red-cross mark
06:18 and error message reads: system cannot be resolved.
06:23 This means, Java is expecting a class or object or a variable by the name 'system'.
06:28 But there is nothing like 'system' object in the code.
06:33 So, let us look at the possible fixes.
06:39 There are 11 fixes. Out of these, the fix that we are looking for is the eighth option:
06:48 Change to 'System' (java.lang).
06:58 You can see that once we change it to capital 'S', the error is missing.
07:06 Here is how you identify errors in Java, using eclipse, and rectify them.
07:15 This brings us to the end of this tutorial.
07:18 In this tutorial we have seen:
07:20 what are the typical errors while writing a Java program and
07:23 how to identify them and rectify them using Eclipse.
07:30 As an assignment for this tutorial, find out the errors in the code given below and fix them.
07:39 To know more about the Spoken Tutorial project,
07:42 watch the video available at the following link. It summarizes the project.
07:48 If you do not have good bandwidth, you can download and watch it.
07:53 The Spoken Tutorial Team conducts workshops using spoken tutorials.
07:57 Gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org.
08:07 Spoken Tutorial Project is a part of the Talk to a Teacher project.
08:11 It is supported by the National Mission on Education through ICT, MHRD, Government of India.
08:17 More information on this mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro
08:23 This tutorial has been contributed by TalentSprint.

Thanks for joining.

Contributors and Content Editors

Gaurav, Madhurig, PoojaMoolya, Pravin1389, Sandhya.np14, Sneha