Java Reference
In-Depth Information
A better solution is to permanently associate .java files with the
text editor you'll be using: In Windows, open the folder that con-
tains HelloUser.java and double-click the file. If you have never
opened a file with the .java extension, you'll be asked what pro-
gram to use when opening files of this type. Choose your pre-
ferred editor and select the option to make your choice
permanent. From this point on, you can open a source file for edit-
ing by double-clicking the file.
TIP
The purpose of this project is to test the Java Development Kit—none of the Java
programming concepts used in the six-line HelloUser program are described in this
appendix.
You'll learn the basics of the language .during the first several days of Week 1, “The Java
Language.” If you have figured out anything about Java simply by typing in the source
code of Listing A.1, it's entirely your own fault.
Compiling and Running the Program in Windows
Now you're ready to compile the source file with the kit's Java compiler, a program
called javac . The compiler reads a .java source file and creates one or more .class
files that can be run by a Java interpreter.
Open a command-line window and then open the folder where you saved
HelloUser.java .
If you saved the file in the J21work folder inside the root folder on your main hard drive,
the following MS-DOS command opens the folder:
cd \J21work
When you are in the correct folder, you can compile HelloUser.java by entering the
following at a command prompt:
javac HelloUser.java
Figure A.10 shows the MS-DOS commands used to switch to the \J21work folder and
compile HelloUser.java .
The kit's compiler does not display any message if the program compiles successfully. If
there are problems, the compiler enables you to know by displaying each error along
with a line that triggered the error.
Search WWH ::




Custom Search