Java/C2/Errors-and-Debugging-in-Eclipse/English-timed

From Script | Spoken-Tutorial
Revision as of 17:24, 22 August 2014 by PoojaMoolya (Talk | contribs)

Jump to: navigation, search
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 error 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]http://spoken-tuitorial.org
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 filename and classname and
00:52 And 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 Error Free and select methods stubs public static Void main
01:37 Let us minimise the package explorer. Remove the comments and add the print statement to the few errors
02:23 In Eclipse, the line which has the error will be indicated with a red cross mark on the left margin.

Java/C2/Errors-and-Debugging-in-Eclipse/English-timed

02:35 In this case, the System.out.println line has an errors and hence their is the 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 semi-colon and save the file, the first error is gone.
03:21 their is only one error now which says; hello world 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 have gone and the program is error free. So let us run the program and see what happens.
04:10 Run as 'Java applications
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 file name and class name.


04:29 It does not happens 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, their is the 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 errorfreeis 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 to 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 their 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, 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 error 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 summarises 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