 | First prepare a Java source file.
Open Notepad and type in your Java program. Use the following for a test
if needed.public class Test {
public static void main(String[] args) {
System.out.println("hello java");
}
}
|
 | Save your Java program. Save it
with the same name as the class. In this case you would use Test.java,
case is important! If you are using an old Windows computer you may have
to put "Test.java" quotes around the name when you save it. If you don't,
you will get Test.java.txt and it won't work! ALSO when you save it, save
it somewhere easy to find. Save it into a new folder you create as you
save it the first time, call this folder Test (or something easy to
remember).
|
 | Now you should have saved your file into a new folder. Open a DOS
Command Prompt Window. Most folks have a
Command Prompt option in their Accessories menu (under the Start menu).
|
 | At the prompt enter the following to move to the top level folder:
cd \
This should result in getting something like the following screen:

|
 | Next change directory into the
folder where you saved your Java program. So if I saved mine into the Temp
folder I'd type:
cd Temp

|
 | Now I can use the DIR directory
command to see if my Java file is here.

|
 | There are several things I can do now for convenience. The DOSKEY
command (already active on some Windows OSs) allows commands to be
repeated easily. You can also set your path
temporarily to allow easy access to the Java tools. To set your path type
the following:
set path=C:\jdk1.3.1\bin;%path%
Note: You must make sure you set the path for the Java install directory
correct for your computer. Mine is actually C:\jsdk1.4.0.

|
 | Now we can try compiling. Type
javac and the name of your Java program:
javac Test.java

Note: You may get compiler errors if your program
syntax is not correct. Edit, save and
try again.
|
 | We can see the .class file that is produced by the compiler by typing
the DIR command again.

|
 | Next we can run the Java program
with the java command and the name of our program:
java Test

|
 | In the example above the program had no errors and ran correctly. The
output was simply Hello java. If you have a syntax error in your program
you would go back to Notepad, edit the program, Save it, and then compile
it again. |