School of Engineering and Applied Science
Department of Computer Science
CSci 133 -- Algorithms and Data Structures I
http://www.seas.gwu.edu/~csci133/fall03
Prof. Michael B. Feldman
mfeldman@gwu.edu

Lab Exercise #1
Wednesday, Sep. 3, 2003
You must complete this laboratory in order to proceed with the course. If, for any reason, you cannot finish it during the lab session, you must finish it by 5 PM, Friday, September 5, 2003.

Objectives: The purpose of this lab is to give you some practice in organizing and manipulating your Unix file system, and to get ready to use the program distribution that the course textbook provides. In working with Java beyond an introductory course, it is really important to understand directory structures, because Java compilers require a correspondence between your package/class structure and your directory structure.

Step 1: Make sure you have both GW and SEAS accounts.

You will need a SEAS computer account to do the work in this course. On your lab PC, open an SSH window and log in to the SEAS server, hobbes.seas.gwu.edu. If you can't log in, find out why and do whatever you must do so that you can log in to hobbes.

Step 2: Bring your filesystem up to the CSci 53 state.

At the end of this step, you will have, in your home directory,

Step 3: Set up your CSci 133 directory structure.

There is no special setup script for this course, because it's useful for you to understand the details of your file system by setting up some of it yourself. 

  1. First modify your .kshrc file to let the Java compiler know how to find all your Java files.

  2. The .kshrc file (short for "Korn Shell startup file") contains commands that are executed each time you enter a copy of the shell -- when you log in, when you call jcompile, etc. Move to your top-level directory, and bring .kshrc into your editor. It should contain the line . ~csjava/csci53.profile. Immediately below this line, add the line
    export CLASSPATH=~:~/csci53:~/csci133:$CLASSPATH
    which extends the path the compiler should take in looking for Java sources and class files. In Unix, the symbol ~ ("tilde") refers to the home directory.
     
  3. Now learn some useful variants of the Unix ls command.

  4. Move to your top-level directory, and type each of the following, noting down a description of what each one displays. Note that these are lower case L's and not numeral 1's.
    ls -a
    ls -l
    ls -al
    ls -alR
    ls -R
    The last variant will be very useful in this lab. Each time this handout says "list your file system", use the last command above.
     
  5. Now make a directory structure for the course.

  6. In your top-level directory, type
    mkdir csci133
    and then
    mkdir csci133/mbf
    mkdir csci133/cs1

    The first directory is where you'll do much of your work; the mbf subdirectory is where you'll store the reusable classes Prof. Feldman will provide and the cs1 subdirectory holds the Lewis & Loftus class cs1.Keyboard, which provides simple keyboard input methods.

  7. Now set up a "shortcut" to the CSci 133 textbook program library.

  8. Move into your csci133 directory, then type
    ln -s ~csjava/programs133
    which makes the program library visible to you. In CSci 53, all the programs were in one directory (except for Keyboard). In this course, the programs are distributed into the top-level directory and several subdirectories.
     
  9. Now copy a few files from the distribution into your own structure.

  10. Type
    cp
    programs133/mbf/Screen.java mbf
    cp programs133/ShowInputLoop.java .
    cp programs133/cs1/Keyboard.java cs1
    cp programs133/Smiley.java .

    Examine mbf/Screen.java with vi and note that the first actual code line reads package mbf;  
    Examine cs1/Keyboard.java with vi and note that the first actual code line reads package cs1;

    The subdirectory structure matches the package structure. Java compilers REQUIRE this! In this course, whenever you copy a file from the course distribution, you must put it into the equivalent location in your own file system, otherwise you will surely get compilation errors!

      
  11. Now compile the two reusable class files.

  12. Type
    jcompile mbf/Screen.java
    jcompile cs1/Keyboard.java

    You should get successful compilation messages. The listing and class files are in that same subdirectory - try listing that subdirectory to be sure. Also move down into the subdirectory and back.
     
  13. Now compile and run two applications that use the class files:

  14. Type
    jcompile ShowInputLoop.java
    jrun ShowInputLoop
    jcompile Smiley.java
    jrun Smiley

  15. Now read the two applications, and the documentation for the two classes, carefully. You'll be using them.

  16. Congratulate yourself on getting through all this!
(end of lab)