User Tools

Site Tools


cs257:advent_2015

Notes

Compiling against the Textbook code

To do this assignment with the ArrayStack class you need to have downloaded the textbook code If you already did this, great. Otherwise, download it and expand it wherever you like; I put it in my ~/Classes/CS257/Resources directory.

Unlike Objectdraw, the textbook's code is package-based (see Chapter 2 for more about packages). Say you decided to use ArrayStack in this project, you'd import it this way:

import edu.colorado.collections.ArrayStack;

To access it when compiling, add it to your Java classpath. This is the list of directories that javac searches to find the Java libraries we use. In CS157 this was done for you, now you need to learn how to handle this stuff yourself. On the Linux computers I do this:

  • open the file .bashrc in an editor (.bashrc is a hidden file in your home directory)
  • add the line export CLASSPATH=$CLASSPATH:~/Classes/CS257/Resources/dsjava
  • save and issue the command source ~/.bashrc at the command line

Of course, you'll use the path for your installation of dsjava, not mine!

(still using BlueJ? set the classpath in the same you did for objectdraw, see the first step for a reminder)

Alternatively, you can add the class path when you compile. For my installation it would look like:

javac -cp ~/Classes/CS257/Resources/dsjava Simple0.java

The downside is, you have to type that dang classpath each time you issue the compiler command.

Note: you can use the Stack class in java.util if you'd like. Just import it with

import java.util.Stack;

No extra compilation hoops to jump through.

Notes on Project 4 Milestone 2

cs257/advent_2015.txt · Last modified: 2017/02/15 17:52 by scarl