Java Reference
In-Depth Information
A PPLICATIONS VS . A PPLETS
Java programs run in one of three contexts: as an applet, as an application, or as
servlets. I discuss server-side Java programs in more detail toward the end of this
topic in Part III, “Introducing Enterprise Java.”
As the name suggests, an applet is an application fragment. It is not a complete
application but rather an extension of another application. Most often, the appli-
cation extended is a browser, such as Firefox or Microsoft's Internet Explorer. In
fact, any application can be extended with Java applets. The only requirement is
that the application to be extended must provide a Java runtime environment.
Conversely, a Java application is a complete application. It can run as a stand-
alone application and independent of any other application. A Java application still
needs a runtime interpreter, but this interpreter is a standalone program whose
only responsibility is to execute and support Java applications.
A standalone interpreter is often a native program, suitable for executing on the
host platform. For example, Sun's standalone interpreter is named java.exe in Win-
dows, and java in every other environment, and it is executed like any other appli-
cation. Sun provides a version of the Java program for Windows, Linux, and the
Solaris operating systems. The only job of the standalone interpreter is to execute
the Java byte codes and to perform the functions requested by the application.
R EVIEWING THE S AMPLES
I kind of rushed through some of the code and the changes made to it in an effort
to explain the development environment issues, so let's take a minute to review,
starting with the first application.
Your first program was a standalone application . That is, it only needed a run-
time interpreter to execute, which was java.exe.
The main program (the class that gets the ball rolling) in a Java application
must have a specific interface. It must have a public method with this method
definition:
public static void main(String[] args)
This method accepts a single parameter (named args in the example). This
parameter must be defined as an array of Strings ( String[] ). The String
array represents the runtime arguments to the program (as in jview HelloWorld
argument1 argument2 ).
 
Search WWH ::




Custom Search