Using Java in the Campus Computer Labs

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 any computer in the main computer lab in the Powers building or in math department computer lab in CLO 365. 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:
You need to create a directory H:\cs125 on your H: drive. Your H: drive is found inside the "My Computer" icon on the Windows 95 desktop. Think of H: as your "Home directory"; it is 5 MB of storage space on one of the campus file servers and it is reserved for your use only. To create H:\cs125, open H:\ in a directory window, click on the "File" Menu of this directory window, and choose "New" -> "Folder". Call the new folder cs125.

Step 2:
Now you need to download a DOS batch file, javaset.bat. Place this file in your H:\ directory (not in the H:\cs125 directory). When you click on the previous link, if your browser asks where to save the file, save it in H:\. If your browser displays the batch file, then click on the browser's "File" Menu, click on the "Save As" command, and save the batch file in H:\.

Step 3:
Download this very short Java program into the H:\cs125 directory that you created in Step 1. Either right click on the previous link and tell Netscape where to save the file, or click on the previous link, which will display the file in Netscape, and then use the Netscape "File" -> "Save as ..." menu item to save the file.

Step 4:
Now you are ready to try out Java. But first make sure that you have read Chapter 2, pages 10-20, of the "Java for Students" textbook. To compile the short Java program that you just downloaded, use the Start Menu to start up a "MS-DOS Prompt" window. At the DOS prompt, type the DOS command
cd H:\cs125
which will move you to the directory H:\cs125. Now enter the command H:\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 5:
If the last step was successful, then you are ready to try out your own Java program. To familiarize yourself with the Java compilation process, follow the directions on pages 14-17 of the "Java for Students" textbook. For an editor you can use either Notepad (use the "Start Menu" -> "Run" menu item and enter the command "notepad"), or you can use the PFE or TextPad editors (see Step 7 below). After you create a Java program file with an editor, save the file in your H:\cs125 directory. It is a good idea to create a subdirectory of H:\cs125 for each chapter of the book (or create a subdirectory for each Java homework assignment).

Step 6:
When you are done working with Java, it is a good idea to make a copy of your work on a floppy disk. In particular, if you want to work on Java at home, then you need the floppy in order to move your Java files to your home computer. You need a high density floppy disk (there should be enough room on it to hold all your Java programs). Copy the directory H:\cs125 onto the floppy. The easiest way to do this is to put the floppy in the A: drive, open a directory window for H:\ and another window for "My Computer", and then just drag the folder H:\cs125 onto the icon for the A: drive. This creates a directory A:\cs125 on the floppy disk and copies everything from H:\cs125 into A:\cs125.

If you do all of your Java work on the lab computers, then the next time you want to work on Java you just need to open your H:\cs125 directory and begin working. If you do some of your Java programming at home, then when you return to the computer lab you will need to update your H:\cs125 directory using your floppy, which should have on it the latest versions of your java programs.

Step 7:
These last two steps are optional. If you would like to, you can download a good text editor to use instead of Notepad for editing your Java source files. You have your choice of two editors, one shareware and one freeware.

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.

The Latest Version of PFE
You want the 32 Bit Edition of PFE. Download the distribution zip file into your H:\ drive. Once you have the distribution zip file in your H:\ drive, create a directory H:\pfe and extract the zip file into it. You should put a shortcut to PFE on your desktop and/or in your "Send To" folder. Delete the distribution zip file from your H:\ drive after you have unzipped it into H:\pfe. PFE is a pretty compact program; the whole H:\pfe directory will easily fit on a floppy disk, so you can carry the editor around with you (though once it is in your H:\ drive you will always have access to it after you log onto a lab computer).

A very good shareware text editor is TextPad. Since TextPad is shareware, you can download and use it for free for a trial period, but then you are supposed to pay a modest shareware fee if you plan to continue using it. Use the following link to download an installation file.

ftp://ftp.textpad.com/pub/tpe32325.exe
Download this installation file onto your desktop. Double click on the installation file to start the installation process. Have the installation process install TexPad in your H:\ drive; this way it will be available for you to use from any computer on campus that you login to. (The installation process will, by default, put TextPad on the C:\ drive of the computer, which means the program is physically on the computer so it cannot move with you to another computer. At one step in the installation process you need to tell the installer to use the H:\ drive instead of the C:\ drive.) Delete the installation file after TextPad has been installed in your H:\ drive. You should put a shortcut to TexPad in your H:\ drive and then copy that shortcut onto your desktop. Each time you log onto a lab computer you will need to copy this shortcut onto your desktop.

Step 8:
To make it easier to work with the Java language, you can use either the TexPad or the PFE editor as a "developement environment", somewhat like what our textbook describes on page 11. To do this, you need to download three files. Two of these files work with either PFE or TextPad, and the third file is specific to which editor you want to use.

Download the following two DOS batch files into your H:\ drive (not into H:\cs125).

If you are using TextPad as your editor, then download this registry file into your H:\ drive. If you are using PFE as your editor, then download this other registry file into your H:\ drive (these are not the same registry files that you would use on your home computer). When you have one of the registry files in your H:\ drive, double click on it. This will modify the editor so that you have commands built into the editor for compliling a Java program, viewing a Java applet, or running a Java application. We will demonstrate in class how you can use these built in commands. Each time you log onto a lab computer, you will need to double click on a registry file in your H:\ drive in order for the built in commands to show up in TexPad or PFE.

NOTE:
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