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

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


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


Exercise 1

  1. Download the book code:
  2. Unpack the code (be sure you are in your special directory!)

Exercise 2

  1. Change to the newly created code directory:
      cd code
  2. Create a new subdirectory for the source files called src:
      mkdir src
  3. Move the source files into src:
      mv *.java src
      mv weiss src

Exercise 4

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

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/2010S/labs/code/bookcode/prj.el .
  2. Open any source file in Emacs. For instance,
      emacs src/weiss/util/ &
  3. 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.
  4. If you want to compile and run your testing code from within JDE, you'll also need to let it know where your tester.jar file lives. To do this, you can amend the line you changed above to something like:
    (setq jde-global-classpath 
          (quote ("." "somewhere/book/class" 
    being sure that you replace somewhere-else with the appropriate directory you put things in for the testing lab.
Jerod Weinman
Created: 12 January 2009