hello world in the forte ide an introduction to the forte ide (integrated development environment)...

41
Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Upload: melissa-atkinson

Post on 03-Jan-2016

226 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Hello World in the Forte IDE

An introduction to the Forte IDE (integrated development environment)

writing the classic “Hello World” program in Java

Page 2: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Create a folder for your projects

• One way is to use Windows Explorer (WE)

• On the left-hand-side of WE, click on the location where the folder is to be created

• On the right-hand-side of WE, right click in the open area and choose from the menu New and then Folder

Page 3: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Create a New Folder

Page 4: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Rename the FolderRight click on the Folder and choose Rename, then type the name, press ENTER

Page 5: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Start Forte:Start/Programs/Forte for Java CE/ Forte for Java CE

Page 6: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Start Forte (Alternative):Double click on the runidew icon found in forte4j/bin

Page 7: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Close Tip Window(if it appears)

Page 8: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Forte at Startup

Explorer window

Properties window

Main window: menus and toolbars

Desktop showing through

Filesystems, see next slide

Page 9: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Right click on Filesystems (circled on previous slide) in the Explorer Window

Choose Mount Directory from the menu

Page 10: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

The Mount Directory Dialog Box

Page 11: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Use the Mount Directory “Look in” drop-down box to choose a drive and the region below to select a folder

Page 12: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Alternative: Choose File then Mount Filesystem on the Main Window menu to bring up the dialog box shown below

Type the folder’s path or “Browse” for it , then click OK

Page 13: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

To remove any previous Filesystem, right click on it and choose Unmount Filesystem

Page 14: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Java Packages

• In order to facilitate “portability” (moving a program from computer to computer), Java breaks references to a file’s (complete/full) path (its location) into two parts – An external part (known as the CLASSPATH) which

will change as the program is moved around (mounted)

– An internal part which will not change as the program is moved around (package.class)

• The dividing line is a folder known as “a package”

Page 15: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

To create a package for your project, right click on the particular filesystem and choose New Package

Page 16: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Name the packageNOTE: Java’s convention is that only class names are capitalized, Java is case sensitive: hello Hello

small letter

Page 17: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Make your package part of current project (click Yes)

Page 18: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Right click on package folder, select New/Classes/Main

This template (Main) has a method (main) needed to start execution

Page 19: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Name your class;Java convention is that class name are capitalized

Capital letter

Page 20: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Finish

• For the simple Hello World project in this example, one might as well click Finish at this stage

• However, we will step through a series of dialog boxes that may prove useful when writing future projects

Page 21: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Dialog Box #1

Click Next

Page 22: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Dialog Box #2

Page 23: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Dialog box #3

Most classes have fields (or properties) and we could begin to list them here

Page 24: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Dialog box #4

Classes also have methods which could be added here

Page 25: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Make class part of current project

Page 26: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

The Source Editor Window appears.This is where we will type the code.Some code is already provided.

Page 27: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Source editor

comments

package

Beginning of class

Page 28: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Some features

• Comment: anything between /* and */ is a comment — they are ignored by the computer and are there for the sake of the programmer or anyone else reading the code

• The Hello class begins with the line

public class Hello extends Object– public, class and extends are keywords or reserved

words, which is why they are in a different color

Page 29: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Hello World

• For this simple program, we will add just one line to what was supplied by the IDE

• That line is System.out.println(“Hello World.”);

• It belongs inside the curly brackets associated with the main method

• Curly brackets {} set off a unit of coding known as a block

Page 30: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

The main method

the main method

Constructor, not needed for this program

Page 31: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Indenting scheme convention

• Free-formatting: white space (spaces, tabs, returns) are usually ignored by the computer when interpreting Java

• To make the program more readable (not to the computer but to the human beings), certain conventions are followed

• One convention is to place the curly brackets on a line by themselves and have them vertically aligned (indented the same amount) and then anything within the curly brackets is indented further

Page 32: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Start typing the lineAfter typing the period, notice the pop-up menus

Page 33: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Java is case-sensitive

• Java is case-sensitive• In the one line, System (a class) must be

capitalized, out (an object) must not be capitalized• The pop-up menus provide the properties and

methods associated with a class or object • If they do not pop up, it is a good indication that

there is a typo

Page 34: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Hello World Program

Page 35: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Right click on Hello (the class not the package) and choose Compile

Page 36: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

The Output Window appears if there are errors; In this case there is a missing semicolon

Error reported on line 28 although line with missing semicolon is line 27 (free –formatting)

Page 37: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Edit (add semicolon), Compile again, then Execute: Right click on class and choose Execute

Page 38: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Output Window

Page 39: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Execution Shortcut

Page 40: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Build and Compile Shortcuts

Page 41: Hello World in the Forte IDE An introduction to the Forte IDE (integrated development environment) writing the classic “Hello World” program in Java

Windows Explorer