Java Reference
In-Depth Information
Unless you use the Save As command and then choose a different Save as type
to change the file extension, TextPad automatically saves the file with the same
.java extension. If another application, such as Notepad, is used to create the Java
program, the file must be saved in plain text format with the extension .java.
Testing the Solution
The fifth phase of the development cycle is to test the solution. After the program
solution is designed and then implemented in code, it should be tested to ensure
that it runs properly. With Java, testing the solution is a two-step process that
involves (1) compiling the source code and then (2) executing the bytecode.
Compiling the Source Code
Java source code must be compiled before it can be executed. TextPad includes
a Compile Java command on the Tools menu. The Compile Java command uses
the Java compiler command, javac.exe, to translate the Java source code into byte-
code that any machine can interpret. The compilation process creates a new file
for each class and saves it in the same directory as the source code file.
Accessing the Java SDK Compiler
The Java compiler needs to access certain files from the Java SDK.
If you first installed the Java SDK using its setup program and then
installed TextPad, the Java compiler will automatically access the
necessary SDK files when you execute the Compile Java command
in TextPad. If you are compiling Java source code using the com-
mand prompt window, you must use operating system commands
to designate the location of the SDK files each time you open the
command prompt window. See Appendix D for more information
on compiling Java source code at the command prompt.
Perform the following steps to compile the Welcome to My Day program.
To Compile Source Code
1. With the Data Disk in drive A,
click Tools on the menu bar.
The Tools menu is
displayed (Figure 2-27).
Welcome.java
file in Selector
window
Tools menu
Compile Java
command
FIGURE 2-27
(continued)
 
Search WWH ::




Custom Search