Java Reference
In-Depth Information
The path and classpath now are set for the system. When compiling and executing in the
Command Prompt window, the operating system will use these variables to obtain the value of the
location where the SDK was installed on your system and to locate Java class files.
Permanently Changing the Path
If you want to permanently include the path of the Java SDK on your system, click the
Start button on the Windows taskbar and then right-click My Computer. On the short-
cut menu, click Properties. When the System Properties dialog box is displayed, click
the Advanced tab. Click the Environment Variables button. In the System variables list,
click Path and then click the Edit button. When the Edit System Variable dialog box is
displayed, press the RIGHT ARROW to position the insertion point at the end of the
Variable Value text box and then type ;C:\Program Files\Java\jdk1.5.0_02\bin (or
the location where you installed the SDK) to append the text to the end of the existing
string of characters. Click the OK button in each dialog box to accept the new settings.
Compiling Source Code and Running Programs at the Command Prompt
Programmers enter the javac command followed by the full name of the Java source code file in
order to compile the source code into bytecode. You must enter the .java extension when compiling.
Once compiled, the java command will run the bytecode.
The following steps compile and run the Sample Java program located in the Appendices folder
using the Command Prompt window.
To Compile Source Code and Run Programs at the Command Prompt
1. With the Command Prompt window still open, type javac Sample.java and then press the
ENTER key.
The program compiles (Figure D-14). You must enter the .java extension when compiling.
compile command
FIGURE D-14
(continued)
 
Search WWH ::




Custom Search