2. CREATING YOUR FIRST JAVA PROGRAM
The first steps in
creating our
Hello World
program is to create
our Java project
To do this click on
File/New/Project
3. CREATING YOUR FIRST JAVA PROGRAM
This will open the New
Project Wizard.
Select Java Project and
click Next>
4. For the Project Name
type "HelloWorld"
and click Finish
All other fields
can remain in their
default setting
5. After the project has
been created, you
have to create a class.
To do this, go to
File/New/Class
6. Under Source folder browse
and find the src for the project
you created earlier. When
completed the source folder
text field should read
HelloWorld/src
For the class name enter
"HelloWorld"
Make sure that the "public
static void main(string[] args)"
checkbox is checked.
All other fields may be left as
default
Click Finish
7. We have now created both the project and class. These steps will
have to be completed every time we start a new java program.
Once you create a class your .java program should load and look
like this. At this time don't worry about what everything means,
we will cover that as the class moves forward
8. WRITING THE CODE
As you have already learned, Java follows simple syntax when
writing program instructions.
To write the code for Hello World
type the following inside the
main method.
Click Save
9. UNDERSTANDING THE CODE
If we were to break out the line of code we just wrote it would
read as follows.
Computer (system) output (.out) this line (println) Hello World!
("Hello World!";).
10. RUNNING THE CODE
To run your code, click on Run/Run As/Java Application
Doing this will load a dialog box where you select your
HelloWorld.java file. Click OK
You can also click on Run/Run to do the same thing.
11. VIEWING THE CONSOLE
By default you should see the output of your .java program
below in the console section. If the window is not appearing click
on Window/Show View/Console
If the code has been added correctly you should see Hello World
being outputted.
12. HELLO WORLD OVERVIEW
1.Create a project (HelloWorld)
2.Create a class (HelloWorld)
3.Add code (System.out.println("Hello World!");
4.Run code (Run/Run As/Java Application)
These are the four basic steps to all Java programming.
Now Change the Hello World text to say “Your Name” and run
the application.
13. NEED MORE HELP?
Eclipse comes with its own Hello World tutorial. You can access
the tutorial from the Welcome Screen.
To get to the Welcome Screen select Help > Welcome from the
menu bar. Click the tutorials icon and then select Create a Hello
World Application.
This tutorial walks you through the entire Hello World
application building process.