Java/C2/Errors-and-Debugging-in-Eclipse/English
Title: Finding Errors and Debugging using Eclipse
Author: TalentSprint
Keywords: Video tutorial, Errors, debugging, eclipse, java
Visual Clue | Narration |
Slide 1
Welcome |
Welcome to the spoken tutorial on Errors and Debugging using Eclipse. |
Slide 2
Learning Objectives |
In this tutorial, you will learn
about the possible errors in a typical Java Program, how to identify them and how to correct them using Eclipse. |
Slide 3
Software Versions |
For this tutorial we are using
Ubuntu 11.10, Eclipse 3.7 |
Slide 4
Prerequisites |
To follow this tutorial you must know
how to create and run a Java Program in Eclipse.
|
Slide 5
Possible Errors
|
When writing a Java program, here is a list of typical errors we are likely to make.
We shall write a program and then make each of these errors and rectify them in Eclipse |
Minimize slides and maximize Eclipse
{Eclipse should contain the project DemoProject used in previous tutorial}
{ public static void main(String args[]) { System.out.println(Hello World) } } |
Here we have the Eclipse IDE and the skeleton required for the rest of the code.
|
Point to the red cross mark on the margin, left of the line Sytem.out... | In Eclipse, the line which has the error will be indicated with a red cross mark on the left margin.
|
Hover mouse over the cross mark. | The list of errors is displayed by hovering the mouse over the cross mark. |
Pointing at the cross mark on the left of the line System.out.println | The first error displayed in the message box says, insert semicolon.
|
Type ; | So, let us insert the semicolon at the end of the statement.
|
Point back to the cross mark | Now we see that there is only one error and the semicolon error has been recolved..
|
Pointing to the second error.
|
The second error says that HelloWorld cannot be resolved.
|
Type “ ” on both ends of HelloWorld | Let us add double quotes before and after the message, HelloWorld.
|
Run the program | Now we see that the error has been resolved and the program is error free.
|
Output:
HelloWorld |
We see that the message HelloWorld is printed on the console. |
Open the New Java Class Wizard.
Point to the created file name and class name. |
Let us look at the next error.
|
Change ErrorFree to errorfree. | But if we create a Java file outside of Eclipse and add it to a project, the error can occur.
|
Point to the file ErrorFree.java in Project Explorer Portlet | Since Java is case-sensitive, now the class name and file name are different .
|
Mouse over the red cross mark | As we can see, there is a red cross mark on the left of the margin. |
Mouse over the error message
|
The message reads The public type errorfree must be defined in its own file.
|
Mouse over the class name errorfree | Eclipse also offers intelligent fixes.
|
Mouse over the fixes available | We can see the error message and also that there are 2 fixes available
|
Point to the first fix. | The first one is renaming the file to suit the class name. |
Point to the second fix. | The second one is to rename the class name to suit the file name. |
Click Rename
Change errorfree to ErrorFree |
Here, we shall click the second option and rename the class name.
|
Change the word System to system | Let us look at the next error.
|
Point to the red cross mark | We can see that the cross mark reappears.
|
Mouse over the system word | Let us look at the possible fixes..
|
Click on Change to 'System' (java.lang)
|
Out of these, the fix we are looking for is the eighth option.
And we see that the program is error free again. |
This is how we identify errors depending on the error messages and rectify them using Eclipse. | |
Minimize Eclipse and maximize slides
Slide 6 Summary |
We have come to the end of this tutorial.
In this tutorial we have learnt what are the typical errors while writing a Java program and how to identify and rectify them using Eclipse. |
Slide 7
Assignment |
As an assignment for this tutorial, identify and fix the errors in the code given below. |
Slide 8About the Spoken Tutorial Project
|
To know more about the Spoken Tutorial project,
Watch the video available at the following link, that summarises the project.Alternatively, you can download and watch it. |
Slide 9Spoken Tutorial WorkshopsThe Spoken Tutorial Project Team
|
The Spoken Tutorial Project Team. Conducts workshops using spoken tutorials.
|
Slide 10Acknowledgement
|
Spoken Tutorial Project is a part of the Talk to a Teacher project.
|
Slide 11About the contributor
|
This tutorial has been contributed by TalentSprint.
Thanks for joining.
|