Java Reference
In-Depth Information
With the javac program, you compile this file to create a bytecode file (or
files if the source code file included more than one class). The bytecode file ends
with the .class extension appended. Here the output is HelloWorldApp.
class . The bytecode consists of the instructions for the Java Virtual Machine
(JVM).
With the java program you run your class file. The JVM interprets the byte-
code instructions just as if it were a processor executing native machine code
instructions. (In Chapter 24 we discuss hardware processors that directly execute
Java bytecode.)
The platform independence of Java thus depends on the prior creation of a
JVM for different platforms. The Java bytecode can then run on any platform on
which a JVM is available and should perform the same regardless of platform
differences. This “Write Once, Run Anywhere” ideal is a key goal of the Java
language. For applets the browser runs a JVM in the same manner that it runs
other plug-in programs.
1.7.1 Java tools
Programming in Java typically involves two alternative approaches that we will
call manual and graphical :
Manual - Use your favorite text editor to create the java source code files ( *.java )
and use the command line tools in the Software Development Kit (SDK) to compile
and run the programs. The SDK is provided by Sun and includes several tools, the most
important of which are:
javac - compiles Java language source files to bytecode files
java - the JVM that executes java applications
appletviewer - tests applets independently of a web browser.
Graphical - Graphical user interface programming environments (or GUI builders ) are
elaborate programs that allow you to edit Java programs and interactively build graphical
interfaces in a WYSIWYG ( What You See Is What You Get ) manner. They also include
a compiler and a JVM so that you can both create and run Java applets and applica-
tions all within one environment. These are also known as Integrated Development
Environments, or IDEs.
During this course we recommend the manual approach so that you will learn
first hand the essential details of Java graphics programming. While it is fine to
use the editor in the GUI builder or IDE, you should write all of the code yourself
rather than use the interactive user interface building tools. Otherwise, the GUI
builder does most of the work and you learn very little.
When you later begin developing programs for your own tasks that require
graphical interfaces with many components, you may want to use a GUI builder.
However, even then you will occasionally want to modify the graphics code by
Search WWH ::




Custom Search