ptg7068951
WHAT YOU’LL LEARN IN
THIS HOUR:
.How applications work
.Organizing an application
.Sending arguments to an
application
.How applets work
.Organizing an applet
.Putting an applet on a web
page
An important distinction to make in Java programming is where your pro-
gram is supposed to be running. Some programs are intended to work on
your computer. Other programs are intended to run as part of a web page.
Java programs that run locally on your own computer are called
applications. Programs that run on web pages are called applets. During this
hour, you learn why that distinction is important.
Creating an Application
The Salutonprogram you wrote during Hour 2, “Writing Your First
Program,” is an example of a Java application. The next application you
create calculates the square root of a number and displays the value.
With the Java24 project open in NetBeans, begin a new application:
- Choose File, New File. The New File Wizard opens.
- Choose the category Javaand the file type Empty Java File, and
then click Next. - Enter the class name Rootand click Finish.
NetBeans creates Root.javaand opens the empty file in the source editor
so you can begin working on it. Enter everything from Listing 4.1, remem-
bering not to enter the line numbers and colons along the left side of the
listing. The numbers are used to make parts of programs easier to describe
in the book. When you’redone, save the file by clicking the Save All but-
ton on the toolbar.
HOUR 4
Understanding How Java
Programs Work