Difference between revisions of "Java/C2/Errors-and-Debugging-in-Eclipse/English"
Pravin1389 (Talk | contribs) |
PoojaMoolya (Talk | contribs) |
||
Line 7: | Line 7: | ||
{| style="border-spacing:0;" | {| style="border-spacing:0;" | ||
− | | style="border:0.035cm solid #000000;padding:0.097cm;"| '''Visual | + | | style="border:0.035cm solid #000000;padding:0.097cm;"| '''Visual Cue''' |
| style="border:0.035cm solid #000000;padding:0.097cm;"| '''Narration ''' | | style="border:0.035cm solid #000000;padding:0.097cm;"| '''Narration ''' | ||
Latest revision as of 11:54, 17 June 2014
Title: Finding Errors and Debugging using Eclipse
Author: TalentSprint
Keywords: Video tutorial, Errors, debugging, eclipse, java
Visual Cue | Narration |
Slide 1
Welcome |
Welcome to the tutorial on Errors and Debugging using Eclipse. |
Slide 2
Learning Objectives |
In this tutorial,we are going to learn
what are the possible error while writing a simple Java Program, how to identify those errors and rectify 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
|
In a simple Java program, the typical errors could be.
We shall write a program and then make each of these errors and see what happens 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 project used for the HelloWorld tutorial
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 Let us minimise the package explorer. Remove the comments and add the print statement to the few errors |
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 is syntax error insert semi-colon to complete block statements
This is because we have to end every statement of a Java program with a semicolon.
|
Type ; | So, let us insert semicolon at the end of the statement.
|
Point back to the cross mark | notice that once you add a semi-colon and add a file the first error is gone.
. |
Pointing to the second error.
|
their is only one error that 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.
Without the quotes, Java thinks that HelloWorld is the name of a variable.
|
Type “ ” on both ends of HelloWorld | Let us add double quotes before and after the message,
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. |
Run the program | Run as 'Java applications
|
Output:
HelloWorld |
We see that the message has been 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, their is the chance of the error
|
Point to the file ErrorFree.java in Project Explorer Portlet | Since Java is case-sensitive, now the class name and file name do not match .
|
Mouse over the red cross mark | Notice that , there is a red cross mark on the left margin. |
Mouse over the error message
|
And error message reads The public type errorfree must be defined in its own file.
|
Mouse over the class name errorfree | Also notice that the word errorfree underlined in red colour. |
Mouse over the fixes available | Eclipse offers intelligent fixes and we have 2 fixes available here
|
Point to the first fix. | The first one is rename compilation unit to errorfree java |
Point to the second fix. | The second one is to 'rename type to errorfree. |
Click Rename
Change errorfree to ErrorFree |
The fix thatwe 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.
|
Change the word System to system | The next error happens due to typing mistakes in the print statement.
|
Point to the red cross mark | We notice that heir is the red-cross mark
And error message reads system cannot be resolved.
|
Mouse over the system word | Let us look at the possible fixes..
|
Click on Change to 'System' (java.lang)
|
there are 11 fixes out of these fix that we are looking for is the eighth option
Change to 'System' (java.lang)
|
here is how you identify errors in Java using eclipse and rectify them | |
Minimize Eclipse and maximize slides
Slide 6 Summary |
This brings us to the end of this tutorial.
In this tutorial we have seen 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, find out the error in the code given below and fix them |
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.
|