Laboratory: Getting the Book Code
CSC 207 Algorithms and Object Oriented Design Spring 2009

Summary: In this lab, we will download, organize, and compile the standard code accompanying our textbook.

Preparation

  1. Create a directory for the book code to live in:
      mkdir somewhere/book
  2. Go to your new directory:
      cd somewhere/book

Exercises

Exercise 1

  1. Download the book code:
      wget http://users.cs.fiu.edu/~weiss/dsj3/code.tar.Z
  2. Unpack the code (be sure you are in your special directory!)
      tar xZf code.tar.Z

Exercise 2

  1. Create a new subdirectory for the source files called src:
      mkdir src
  2. Move the source files into src:
      mv *.java src
      mv weiss src
    

Exercise 4

  1. Copy the Ant build file to your directory (not the src directory)
      cp ~weinman/public_html/courses/CSC207/2009S/labs/code/bookcode/build.xml .
  2. Run a test of building the code from the command line by running Ant.
     ant
    This should create a directory class where it stores all the compiled class files.

    Oops. It seems Professor Weiss's code has a small error. We'll get to that in just a moment.

Exercise 5

So far so good. Now, we need to configure JDE so that it is aware of your files, and ant, so if you edit any of them you can build directly from within Emacs.
  1. Copy the JDE project file to your directory:
      cp ~weinman/public_html/courses/CSC207/2009S/labs/code/bookcode/prj.el .
  2. Open any the source file causing the compile error in Emacs:
      emacs src/weiss/util/AbstractCollection.java &
  3. Fix the typo.
  4. Now, we are going to build the book code as a JDE project. There are two ways to do this.
    • Select JDE ~ Build
    • Type C-c C-v C-b
    Do one of them now. Contact someone for help if you have any problems (i.e., ant fails to indicate a successful build.)

Exercise 6

Finally, the last thing to do is tell JDE where to find these classes when you compile things. That is to say, we need to add it to your classpath.
  1. Open your ~/.emacs file for editing (probably in Emacs).
  2. Find the line that looks like this:
    (setq jde-global-classpath (quote (".")))
  3. Note that you put the book code in somewhere/book, and you decided where somewhere is. The source files live in somewhere/book/src, and you've just configured the compiled class files to live in somewhere/book/class. Change above line in your ~/.emacs to read instead:
    (setq jde-global-classpath (quote ("." "somewhere/book/class")))
    being sure that you replace somewhere with the appropriate directory you put things in.
Jerod Weinman
Created: 12 January 2009