To support development of Java software, Sun provides a basic set of tools, called the Java Development Kit (JDK). While a number of alternatives are beginning to appear, the discussion that follows presumes use of the JDK.A Java program is written either as a source text file within a conventional editor or as a text file produced by some Java development environment.
Once a source file is produced, it is compiled by the Javac compiler or an alternative. The compiler produces bytecode -- instructions for an abstract machine, called the Java Virtual Machine, as opposed to instructions for a particular computer as is the case with most compilers.
The compiled (bytecode) program can not be run independently; it must be run within the context of an interpreter that implements the Java Virtual Machine. This can be done in two ways. It can be run by the interpreter included with the Java Development Environment or it can be run by an interpreter that is included as part of the Netscape browser (or other "java-enabled" browsers).
Java differentiates between programs that run in the stand-alone interpreter and those that run in a browser. The first are called Applications and the second, Applets. The reason for this difference is that the browser provides additional context, such as a window in which to display the Applet's output, that is not provided by the Java interpreter. Thus, Applets and Applications have different high-level structures.
![]()
Java Data Flow. Shows the flow of Java programs from creation to execution in three contexts..
Applets must be declared as a subclass of the Applet class (
extends Applet
). Furthermore, they should includeinit
,start
,stop
,destroy
methods.Applications must include a
main
method. If the Application needs a window in which to display output, it should be declared as a subclass of Frame (extends Frame
).In order for an Applet to be run, it must be referenced through an Applet tag included in an HTML document. The Applet is then run by referring to the HTML document either by a Java-enabled browser (e.g., Netscape) or by the appletviewer included as part of the JDK.
A Java Application can be run using the Java interpreter, called simply java, included as part of the JDK.