03 eclipse basics & hello world

13
Mobile App:IT Eclipse Basics and Hello World IHS GIRLS TECH CLUB: ECLIPSE BASICS AND HELLO WORLD

Transcript of 03 eclipse basics & hello world

Page 1: 03   eclipse basics & hello world

Mobile App:ITEclipse Basics and Hello World

IHS GIRLS TECH CLUB: ECLIPSE BASICS AND HELLO WORLD

Page 2: 03   eclipse basics & hello world

CREATING YOUR FIRST JAVA PROGRAM

The first steps in creating our Hello World program is to create our Java projectTo do this click on File/New/Project

Page 3: 03   eclipse basics & hello world

CREATING YOUR FIRST JAVA PROGRAM

This will open the New Project Wizard.

Select Java Project and click Next>

Page 4: 03   eclipse basics & hello world

For the Project Name type "HelloWorld" and click Finish

All other fieldscan remain in theirdefault setting

Page 5: 03   eclipse basics & hello world

After the project has been created, you have to create a class. To do this, go toFile/New/Class

Page 6: 03   eclipse basics & hello world

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

Page 7: 03   eclipse basics & hello world

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

Page 8: 03   eclipse basics & hello world

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

Page 9: 03   eclipse basics & hello world

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!";).

Page 10: 03   eclipse basics & hello world

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.

Page 11: 03   eclipse basics & hello world

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.

Page 12: 03   eclipse basics & hello world

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.

Page 13: 03   eclipse basics & hello world

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.