Using Classes from This Book

Problem

You want to try out my examples and/or use my utility classes.

Solution

Download the latest zip file of the booksource files and unzip it. Install the class JAR file in your CLASSPATH. Or download just the files you need.

Discussion

You can download the latest version of the source code for all the examples in the book from the book web site, http://javacook.darwinsys.com. You will get two files. First is the source code, in a file called javacooksrc.jar, which you should unzip someplace convenient or wherever you like to keep source code. Second is a file called com-darwinsys-util.jar, which you need to set in your CLASSPATH (see Section 2.6) or JDKHOME/jre/lib/ext directory. The files are roughly organized in per-chapter directories, but there is a lot of overlap and cross-referencing. Because of this, I have prepared a cross-reference file named index-bychapter.html. There is also a mechanically generated file called index-byname.html, which you can use if you know the name of the file you want (and remember that Java source files almost always have the same name as the public class they contain). The canonical index file, index.html, links to both these files.

Once you’ve set your CLASSPATH, you can compile. In most directories you can simply say javac *.java or jikes *.java . Of course, not everybody likes typing those commands, so there is a makefile for the make utility. make is standard on Unix and readily available for MS-Windows from, for example, the GNUwin32 project (see http://sourceforge.net/projects/gnuwin32/). There is also a top-level makefile that visits the subdirectories and runs make in each of them. These makefiles have been tested with gmake (GNU make 3.79.1), BSD make (OpenBSD 2.8), and they should work with almost any reasonably modern make program or equivalent.

There may also be times when you don’t want to download the entire archive -- if you just need a bit of code in a hurry -- so you can access those index files and the resulting directory, for “anyplace, anytime access” on the same web site.

Get Java Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.