Using JDK

Note that none of these instructions are necessary if you are using an integrated system like CodeWarrior. They apply only to those using the JDK (Java Development Kit) on an IBM PC running (at least) Windows 95.


Before you can use the JDK you need to set up your environment. This assumes that you have JDK1.1.8 installed on your drive C in its standard directory (JDK1.1.8) and you are working from a directory named CSJavaCourse on the same drive.

 

Your autoexec.bat file needs to conatin the line:

CLASSPATH=.;c:\jdk1.1.8\lib\classes.zip

In addition your PATH variable in autoexec.bat should contain

;c:\jdk1.1.8\bin

Note that JDK1.2 (Also called Java 2) is supposed to be able to find its own files. However, you may need a CLASSPATH anyway, in which case it would be something like the following as the base classes are now in a file rt.jar instead of classes.zip:

CLASSPATH=.;c:\jdk1.2\javasoft\jre\1.2\lib\rt.jar

When you run the compiler you get a collection of files ending in the extension .class. There is one for each class and one for each interface you define in the file. These need to be distributed to sub directories of your working directory (CSJavaCourse) according to the packages in which the classes fall.

For example suppose you have a file called SpreadSheet.java that starts out

package spreadsheet;
import java.applet.*
public class SpreadSheet extends Applet
{...
}

The compiler will produce (at least) the file SpreadSheet.class (case sensitive). This file needs to be put into the directory named spreadsheet so that the path to it is .\spreadsheet\SpreadSheet.class.

If you don't do this the class loader won't find the class file when you try to run your program. If you choose not to use packages then all of the .class files need to be in the working directory.

You can make the complier distribute the .class files for you. To do this you can either have your environment (Kawa, for example) distribut these for you, or if you are using the "naked" JDK, use the -d switch with the compiler with a single period as the argument. The files will be distributed to subdirectories of your current directory according to their package names.

javac -d . SpreadSheet.java

So you will get a new directory CSJavaCourse\spreadsheet and all of the .class files will be put there. This is where they need to be to run the code.


Using Kawa

You must set up Kawa if you want to use it.

You can learn more about setting it up on the Kawa Page.


Using the Dick Chase Editor

You must also set up the Dick Chase Editor if you intend to use it.

From the File menu select Configure Editor. Thin click on the External Applications tab and finally enter the path to your particular java compiler into this window. It might be something like: c:\java1.1.8\bin\javac.exe. You can use the Browse button to do this or you can type it. You may also need to set up a path to a Web Browser. (See above if you use JDK1.2)

You also need to add all of the files in your program to the project (and save the project). You can select Add File to Project from the Project menu. In the resulting file dialog you can control click all of the .java files in your project and then press the Open button. You will get a Project Options window as well as all of the .java file windows. In the Proect Options window select the Compiler Options tab and type a period "." into the Output Directory box.

Each file window within the editor has a toolbar. The icon farthest to the right (a coffee cup) compiles the .java file in that window.

Don't forget to save your project file. You can select Save Project As... from the File menu. It should have an extension ".jpr".

You can run your java program by selecting Run Java from the Run menu. You will get a dialog box that should have all of the parameters of the java command. Don't forget to preface any program name with its package name. To run the spreadsheet program in the above section, the Command Line would be spreadsheet.SpreadSheet, noting the period separating the two parts of the command. Note that this command, like the CLASSPATH is case sensitive.