Hello World in the Forte IDE
Download
Report
Transcript Hello World in the Forte IDE
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
Create a New Folder
Rename the Folder
Right click on the Folder and choose
Rename, then type the name, press
ENTER
Start Forte:
Start/Programs/Forte for Java CE/
Forte for Java CE
Start Forte (Alternative):
Double click on the runidew icon
found in forte4j/bin
Close Tip Window
(if it appears)
Forte at Startup
Main window: menus
and toolbars
Explorer window
Properties window
Desktop showing through
Filesystems, see next slide
Right click on Filesystems (circled on
previous slide) in the Explorer Window
Choose Mount
Directory from the
menu
The Mount Directory Dialog Box
Use the Mount Directory “Look in”
drop-down box to choose a drive and
the region below to select a folder
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
To remove any previous Filesystem,
right click on it and choose Unmount
Filesystem
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”
To create a package for your project,
right click on the particular
filesystem and choose New Package
Name the package
NOTE: Java’s convention is that only
class names are capitalized, Java is
case sensitive: hello Hello
small letter
Make your package part of
current project (click Yes)
Right click on package folder,
select New/Classes/Main
This template
(Main) has a
method (main)
needed to start
execution
Name your class;
Java convention is that class name
are capitalized
Capital letter
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
Dialog Box #1
Click Next
Dialog Box #2
Dialog box #3
Most classes have fields (or
properties) and we could begin
to list them here
Dialog box #4
Classes also have methods
which could be added here
Make class part of current project
The Source Editor Window appears.
This is where we will type the code.
Some code is already provided.
Source editor
comments
package
Beginning
of class
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
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
The main method
Constructor,
not needed for
this program
the main
method
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
Start typing the line
After typing the period, notice the popup menus
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
Hello World Program
Right click on Hello (the class not
the package) and choose Compile
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)
Edit (add semicolon), Compile
again, then Execute: Right click on
class and choose Execute
Output Window
Execution Shortcut
Build and Compile Shortcuts
Windows Explorer