Difference between revisions of "Java/C2/Hello-World-Program-in-Eclipse/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with ''''Title of script''': HelloWorld in Java using Eclipse '''Author''': TalentSprint '''Keywords: '''HelloWorld, class, public, video tutorial {| style="border-spacing:0;" | s…')
 
Line 21: Line 21:
  
 
'''Learning Outcomes'''
 
'''Learning Outcomes'''
| style="border:0.035cm solid #000000;padding:0.097cm;"| In this tutorial, you will learn to write a simple program in '''Java '''using '''Eclipse.'''
+
| style="border:0.035cm solid #000000;padding:0.097cm;"| In this tutorial, we are  going to  learn how  to write a simple helloWorldin '''Java '''using '''Eclipse.'''
  
 
|-
 
|-
Line 37: Line 37:
  
 
'''Pre-requisites'''
 
'''Pre-requisites'''
| style="border:0.035cm solid #000000;padding:0.097cm;"| For this tutorial, you should have Eclipse installed on your system.
+
| style="border:0.035cm solid #000000;padding:0.097cm;"| To follow this tutorial you must have Eclipse installed on your system.
  
  
You should know how to create, save and run a file in Eclipse.
+
and You must know how to create, save and run a file in Eclipse.
  
  
Line 52: Line 52:
  
 
System.out.println("Hello World");  
 
System.out.println("Hello World");  
| style="border:0.035cm solid #000000;padding:0.097cm;"| Here is the java program that prints the message '''Hello World'''
+
| style="border:0.035cm solid #000000;padding:0.097cm;"| Here is a line java code that prints the message '''Hello World'''
  
  
Let us try this program on '''Eclipse'''.  
+
Now Let us try   on '''Eclipse'''.  
  
 
|-
 
|-
Line 61: Line 61:
  
 
'''Alt + F2 > eclipse'''
 
'''Alt + F2 > eclipse'''
| style="border:0.035cm solid #000000;padding:0.176cm;"| Press '''Alt''' and '''F2''' and type eclipse in the dialog box and hit enter.
+
| style="border:0.035cm solid #000000;padding:0.176cm;"| Press '''Alt''' and '''F2''' and in the dialog box type eclipse  and hit enter. Click Ok to Workspace
  
  
We see the Eclipse IDE.
+
And here we have Eclipse IDE.
  
 
|-
 
|-
 
| style="border:0.035cm solid #000000;padding:0.176cm;"| Click on '''File > New > Project'''
 
| style="border:0.035cm solid #000000;padding:0.176cm;"| Click on '''File > New > Project'''
| style="border:0.035cm solid #000000;padding:0.176cm;"| Now we will create a project.
+
| style="border:0.035cm solid #000000;padding:0.176cm;"|Now let us add a new project
  
  
So click on '''File menu,''' go to '''New '''option and click on '''Project '''option.
+
  click '''File '''   '''New ''' and select '''Project '''
  
 
|-
 
|-
Line 78: Line 78:
  
 
Click''' Next'''
 
Click''' Next'''
| style="border:0.035cm solid #000000;padding:0.176cm;"| Select '''Java Project '''option in the list of '''Wizards''' and click '''Next.'''
+
| style="border:0.035cm solid #000000;padding:0.176cm;"|In the list of project Select '''Java Project '''and click'''Next.'''
  
  
Line 84: Line 84:
  
 
|-
 
|-
| style="border:0.035cm solid #000000;padding:0.097cm;"| Type '''DemoProject'''
+
| style="border:0.035cm solid #000000;padding:0.097cm;"|In the project name  Type '''DemoProject'''
  
  
 
Click''' Finish'''
 
Click''' Finish'''
| style="border:0.035cm solid #000000;padding:0.097cm;"| Type '''DemoProject '''(without spaces) in the project name.
+
| style="border:0.035cm solid #000000;padding:0.097cm;"|In the project name  Type '''DemoProject'''
 +
Please note that their is no space between '''Demo and Project '''
  
 +
  '''D '''and '''P '' are in  capital letters.
  
Note that the '''D '''and '''P '''in the project name are in uppercase.
 
  
 
+
Click '''Finish''' at the bottom right corner of the wizards. The '''DemoProject''' has been created
Click on '''Finish'''
+
  
 
|-
 
|-
 
| style="border:0.035cm solid #000000;padding:0.176cm;"| Point to the '''Project Explorer portlet''' on the left.
 
| style="border:0.035cm solid #000000;padding:0.176cm;"| Point to the '''Project Explorer portlet''' on the left.
| style="border:0.035cm solid #000000;padding:0.176cm;"| Now '''Right click''' on the '''DemoProject '''and go to '''New''' option and select '''Class'''
+
| style="border:0.035cm solid #000000;padding:0.176cm;"|Now let us add a new class  to the project.  '''Right click''' on the ''' Project '''   '''New''' and select '''Class'''. In the class name  type '''DemoProgram''' and in the method stuff select one that says''' Public, Static,Void main'''
 
+
Click Finish at the bottom right corner of the wizard.
 
+
 
This opens a '''New Java Class Portlet'''
 
This opens a '''New Java Class Portlet'''
  

Revision as of 13:45, 7 May 2013

Title of script: HelloWorld in Java using Eclipse

Author: TalentSprint

Keywords: HelloWorld, class, public, video tutorial


Visual Cue Description
Slide 1

Welcome

Welcome to the spoken tutorial on HelloWorld in Java on Eclipse.
Slide 2

Learning Outcomes

In this tutorial, we are going to learn how to write a simple helloWorldin Java using Eclipse.
Slide 3

Tools Used

For this tutorial we are using

Eclipse 3.7.0 and

Ubuntu 11.10

Slide 4

Pre-requisites

To follow this tutorial you must have Eclipse installed on your system.


and You  must know how to create, save and run a file in Eclipse.


If not, for relevant tutorial please visit our website as shown.

Slide 5

"HelloWorld"


System.out.println("Hello World");

Here is a line java code that prints the message Hello World


Now Let us try   on Eclipse. 
Minimize slides and launch Eclipse

Alt + F2 > eclipse

Press Alt and F2 and in the dialog box type eclipse and hit enter. Click Ok to Workspace


And here we have Eclipse IDE.

Click on File > New > Project Now let us add a new project


 click  File    New   and select Project 
Select Java Project.


Click Next

In the list of project Select Java Project and clickNext.



In the project name Type DemoProject


Click Finish

In the project name Type DemoProject
Please note that their is no space between Demo and Project  
 'D and P  are in  capital letters.


Click Finish at the bottom right corner of the wizards. The DemoProject has been created

Point to the Project Explorer portlet on the left. Now let us add a new class to the project. Right click on the Project New and select Class. In the class name type DemoProgram and in the method stuff select one that says Public, Static,Void main

Click Finish at the bottom right corner of the wizard.

This opens a New Java Class Portlet



Point to the New Java Class portlet


Point to the list of method stubs


Click Finish


Type DemoClass (without spaces) in the Name field.


Note that the D and C in the class name are in upper case.


Select the public static void main option.


Then click on Finish at the bottom right corner of the wizardPrathamesh Salunke:

Also try to keep one activity in one row..

Point to the src directory in Project Explorer Portlet Eclipse creates a file with the name called DemoClass.java .


It is in the src directory of our project.


In Java, every class is a file.


So, the Class name and the File name must match.


In our case, class name is DemoClass and hence the file name will be DemoClass.java

Point to the “code editor”


Type in Eclipse

After the line “public static void main”


System


System.out.println(


System.out.println(“)


System.out.println(“HelloWorld”);


Press Ctrl + S

As we can see, Eclipse has filled most of the code in the program.


We will learn about all this once we get some output.


Let us type the print statement.


As we can see, Eclipse suggests various possibilities as we type a command.


Let us complete the command.


Eclipse also completes the parentheses by automatically adding the closing parentheses.


Let us add the statement that we want to print.


The message has to be included in double quotes.


As we can see, Eclipse also completes the quotes by adding the closing quote.


There is a semicolon at the end of the statement.


Every statement in Java must end with a semicolon.


Now our program is complete.


Save the file by pressing Ctrl + S simultaneously..

Click on the code editor Now let us compile and execute the program.


Right click on the source code, go to Run as option, and then click java application.

Point to output console at the botom of the code editor The output message HelloWorld is displayed in the console window.


So we have written a simple java program and executed it successfully.

Replace HelloWorld with Hello Java and run the code. Now, let us change the code to print a different message.


Replace HelloWorld with Hello Java and run the code.


As we can see, the message printed now is Hello Java

Point to the line public class DemoProgram


Point to the line public static void...


Point to the opening and closing braces


Select from opening to closing braces of the class.


Select from opening to closing braces of the main method.

Now let us understand the program piece by piece.


The line class DemoProgram indicates that the name of our class is DemoProgram.


This is required since every source file in java is a class.


The next line defines the main method.


It is the code inside main method that will be executed when you run a java program.


The opening and closing braces suggest which part of code goes under which name.


This block of code belongs to the DemoProgram class.


This block of code belongs to the main method.

Minimize the Eclipse window and switch to slides.


Slide 6

Summary

We have come to the end of this tutorial.


In this tutorial we have learnt how to write 'HelloWorld' program using Eclipse.

We have also understood what each piece of the program does.

Slide 7Assignment


Create a java class by the name Greet that prints Program Successful when executed.
Slide 8About the Spoken Tutorial Project
  • It summarises the Spoken Tutorial project
  • If you do not have good bandwidth, you can download and watch it


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
  • Conducts workshops using spoken tutorials
  • Gives certificates for those who pass an online test


The Spoken Tutorial Project Team.

Conducts workshops using spoken tutorials.


Gives certificates for those who pass an online test. For more details, please write to contact AT spoken HYPHEN tutorial DOT org.

Slide 10Acknowledgement
  • Spoken Tutorial Project is a part of the Talk to a Teacher project
  • It is supported by the National Mission on Education through ICT, MHRD, Government of India
  • More information on this Mission is available at

http://spoken-tutorial.org/NMEICT-Intro

Spoken Tutorial Project is a part of the Talk to a Teacher project.


It is supported by the National Mission on Education through ICT, MHRD, Government of India.


More information on this Mission is available at spoken HYPHEN tutorial DOT org SLASH NMEICT HYPHEN Intro

Slide 11About the contributor
  • This tutorial has been contributed by TalentSprint
  • www.talentsprint.com
  • Thanks for joining


This tutorial has been contributed by TalentSprint.


Thanks for joining.



Contributors and Content Editors

Chandrika, Sneha