Using Java in the campus computer lab

The Java compiler that we will start out using is available for free to anyone who wants to install it on a computer (you can install it on your home computer if you wish). It is provided by Sun Computer, the company that invented the Java programming language. This compiler is not as convenient to use as a commercial compiler, but it is good enough for starting out with. The instructions below explain how to use this compiler on the computers in the campus computer lab. Java is installed on the new Pentium II computers; ask a lab assistant which ones these are. The instructions are a series of steps that you should perform. Keep the browser running and open to this page as you go through these steps (or print out this page on a printer).

Step 1:
If you the program WinZip is not already installed on the computer that you are using (look to see if it is in the Start menu), then you need to install it first. Download the Windows 95 version from the WinZip Download Page; follow the instructions on that page to install WinZip.

Step 2:
You need to create a directory C:\cs125 on the C: drive. To create C:\cs125, open C:\ in a directory window, click on the "File" Menu of this directory window, and choose "New" -> "Folder". Call the new folder cs125.

Step 3:
Now you need to download a file created by the author of our textbook. Download the file by clicking on the following URL; have your browser save the file in the directory C:\cs125 that was created in Step 2.
http://www.horstmann.com/ccj/ccjfiles.zip

Step 4:
You need to "unzip" the compressed file ccjfiles.zip that you downloaded in the last step. This is where you need WinZip. Right click on the file C:\cs125\ccjfiles.zip. If WinZip is installed properly, a menu will pop up containing the choice "Extract to..."; click on this choice. You need to "Extract To" the directory C:\cs125. Either type C:\cs125 directly into the "Extract To" box, or use the directory tree in the center of the window to choose the directory C:\cs125. Then click on the "Extract" button. After you have unzipped the file ccjfiles.zip, delete it from C:\cs125.

Step 5:
You need a blank, high density floppy disk. Copy the entire directory C:\cs125 onto the floppy. The easiest way to do this is: put the floppy in the A: drive, open a directory window for C:\ and another window for "My Computer", and then just drag the folder C:\cs125 onto the icon for the A: drive. This creates a directory A:\cs125 on the floppy disk.

Step 6:
Now you are ready to try out Java. But first read Section 1.8, pages 21--22, and Section 1.10, pages 28--30, from the Java textbook. To compile a Java program, use the Start Menu to start up a "MS-DOS Prompt" window. At the DOS prompt, type the DOS command
cd C:\cs125\ch1
which will move you to the directory C:\cs125\ch1. Now enter the command javaset (which should respond with a line of output beginning with the word PATH). Now enter the command javac (you should get a usage message back from the java compiler). Now enter
javac Hello.java
(you should NOT get any output back). Now type
java Hello
(you should get the output Hello, World!).

Step 7:
Read Section 1.11, pages 26--28 (including the Common Error 1.2 on page 28). To familiarize yourself with the Java compilation process, try out the changes to the Hello.java program mentioned on pages 26 and 28.

Step 8:
Move any Java program files that you created in Steps 6 or 7 from the directory C:\cs125\ch1 to the directory A:\cs125\ch1 on your floppy. This is how you save your work so that you can come back to it latter on. There is a subdirectory of C:\cs125 for each chapter of the book. These directories contain example programs from the textbook, and you can keep your own work in them also. When you return to the lab to work on Java again, you will do the reverse of Step 5; you will copy the directory A:\cs125 from your floppy disk to the C: drive, creating the directory C:\cs125 from which you will do your work.

Step 9:
This last step is optional. If you would like to, you can download a good text editor to use instead of Notepad for editing your Java source files. A good freeware editor is the Programmer's File Editor (PFE). Since PFE is freeware, you can use it for as long as you wish, without having to pay. Use the following link to download the distribution zip file.
http://www.lancs.ac.uk/people/cpaap/pfe/pfe0702i.zip
Once you have the distribution zip file, create a directory C:\pfe and extract the zip file into it. You need to create your own program group for the start menu, or better yet, put a shortcut to PFE on your desktop and/or in the folder "C:\Windows\Send To". Delete the distribution zip file after you have unzipped it into C:\pfe. PFE is a pretty compact program; the whole C:\pfe directory will fit on a floppy disk, so you can carry the editor around with you.

When you are editing your Java source files with any editor, remember to save your work frequently (at least every 15 minutes), otherwise it may be Abort, Retry, Ignore?


Return to the main Java page.
Return to the CS 125 home page.


compliments and criticisms