Organization of the CD-ROM for Java Programming on Linux

This is the online version of the CD-ROM for Java Programming on Linux, by Nathan Meyers.

Sources From Examples and Projects in the Book

Sources to the tools and examples in the book are provided in subdirectories named for the chapter in which the code is discussed. The specific code and subdirectories are:

Chapter02/
Examples/: C++ and Java code examples from Chapter 2. The version at this site includes a minor fix to a wordtree.C bug - the absence of a copy constructor for the ErrorMsg class.
Chapter03/
Examples/: Java code examples from Chapter 3.
SlideShow/: An image viewer that demonstrates image enhancement capabilities of the JDK1.2 Graphics2D class.
WaterFall/: A demonstration of JDK1.2 Graphics2D font rendering capabilities, using a typographic waterfall chart to illustrate antialiasing and fractional font metrics.
Chapter14/
font.properties: An example JDK1.2 configuration file to use non-default fonts with the AWT.
ShowFonts11/: A JDK1.1 GUI-based font-listing utility.
ShowFonts12/: A JDK1.2 GUI-based font-listing utility.
Chapter38/
Examples/: C++ and Java code examples from Chapter 38.
Chapter47/
DumpClass/: A utility to dump a list of class members, DumpClass includes information about ancestor classes organized into convenient groupings.
DumpClass11/: A JDK1.1 version of DumpClass
Chapter48/
JMakeDepend/: A development tool that enables the use of GNU make for managing Java projects. A subdirectory is included, SampleCase/, that illustrates the use of JMakeDepend with the example files used in Chapter 48.
JMakeDepend11/: A JDK1.1 version of JMakeDepend
Chapter55/
FileStatus/: An example implementation of a JNI-based component that accesses native platform capabilities to retrieve file ownership and permissions information not supported by Java's file classes.
Chapter56/
XClipboard/: A JNI-based Java class that provides access to X Window System cut and paste capabilities beyond what is available in the AWT's datatransfer classes.
xwinwrap/: A utility library that allows you to run Java (and other GUI apps) with non-standard colormaps and visuals. The version provided here has been updated since the version shipped with the book - see the README file for the details.
Chapter57/
FontPerf/: A font rendering benchmark that demonstrates how font rendering performance is affected by choice of AWT (JDK1.1 versus JDK1.2) and the use of single- or double-buffering.
memstress/: A native C benchmark that illustrates the relationship between data locality and system performance.
Chapter58/
Examples/: C code examples from Chapter 58.
Chapter59/
BackingStore/: An example implementation of backing store as a performance enhancement technique for graphics and GUI applications.
Chapter60/
PerfAnal/: A GUI-based performance analysis tool, used in conjunction with the JDK1.2 hprof profiler to identify application performance bottlenecks.
Chapter64/
Profiler/: A performance analysis tool, usable under JDK1.2, that identifies time spent in native code (in the JVM itself, in native libraries, and in JIT-compiled code) during Java application execution.
Chapter67/
PhoneBook/: Source for an example implementation of a three-tier application architecture implementing database access.

Binaries From the Book

Java Binaries

The Java binaries for the following tools, utilities, and demos are packaged into a single Java archive, JavaLinuxBook.jar, in the top-level directory of the CD-ROM. You can add this single jarfile to your class path to use any of these programs:

Project

Class Name

SlideShow

com.macmillan.nmeyers.SlideShow

WaterFall

com.macmillan.nmeyers.WaterFall

ShowFonts11

com.macmillan.nmeyers.ShowFonts11

ShowFonts12

com.macmillan.nmeyers.ShowFonts12

DumpClass

com.macmillan.nmeyers.DumpClass

DumpClass11

com.macmillan.nmeyers.DumpClass11

JMakeDepend

com.macmillan.nmeyers.JMakeDepend

JMakeDepend11

com.macmillan.nmeyers.JMakeDepend11

FileStatus

com.macmillan.nmeyers.FileStatus

XClipboard

com.macmillan.nmeyers.XClipboard

FontPerf

com.macmillan.nmeyers.FontPerf

BackingStore

com.macmillan.nmeyers.BackingStore

PerfAnal

com.macmillan.nmeyers.PerfAnal

Profiler

com.macmillan.nmeyers.Profiler

The details of running these programs are provided in the section "How to Run the Programs".

Native Binaries

For native software provided in the book, binary code usable in a glibc environment is included in the top-level glibc/ directory. If you need binaries for use in a libc5 environment (or any other Linux or UNIX environment), you will need to build them from source. All relevant source, plus a Makefile, is provided in the project source directories.

The following native components are provided on this CD-ROM:

Project

Component Name

Source Directory

FileStatus

libFileStatus.so

Chapter55/FileStatus/

XClipboard

libXClipboard.so

Chapter56/XClipboard/

xwinwrap

xwinwrap.so

Chapter56/xwinwrap/

memstress

memstress

Chapter57/memstress/

Profiler

libProfiler.so

Chapter64/Profiler/

How to Run the Programs

To describe how to run these programs, we first define some environment variables for convenience:

Here are some brief instructions for running the projects provided on the CD-ROM:

SlideShow (JDK1.2 only)

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.SlideShow [<width> <height>]

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.SlideShow 200 200

You must provide a list of images to be displayed (such as .gif and .jpg files) to stdin.

WaterFall (JDK1.2 only)

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.WaterFall <font family> <style> <min_size> <max_size> <increment>

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.WaterFall serif plain 10 20 1

ShowFonts11

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts11 [<font families>]

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts11

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts11 serif sansserif

ShowFonts12 (JDK1.2 only)

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts12 [<font families>]

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts12

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.ShowFonts12 serif sansserif

DumpClass (JDK1.2 only)

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.DumpClass [-public] [-protected] [-package] [-private] [-suppress:{name,interfaces,hierarchy,headings,keys,all}] [-noancestors] [-inaccessible] <classes>

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.DumpClass java.lang.Object

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.DumpClass -suppress:keys,headings java.lang.Object

DumpClass11 (JDK1.1 only)

The JDK1.1 version has a dependency on the Sun Collections classes. Synopsis:

java -classpath $CLASSPATH:$JARFILE:$COLLECTION com.macmillan.nmeyers.DumpClass11 [-public] [-protected] [-package] [-private] [-suppress:{name,interfaces,hierarchy,headings,keys,all}] [-noancestors] [-inaccessible] <classes>

For example:

java -classpath $CLASSPATH:$JARFILE:$COLLECTION com.macmillan.nmeyers.DumpClass11 java.lang.Object

java -classpath $CLASSPATH:$JARFILE:$COLLECTION com.macmillan.nmeyers.DumpClass11 -suppress:keys,headings java.lang.Object

JMakeDepend (JDK1.2 only)

Note that the version of JMakeDepend on the CD-ROM has been enhanced since the version described in the book. You can read about the details in the README file. Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.JMakeDepend [-noinner] [-sourcepath <path>] [<class files>]

For example (assuming class file names will be fed to stdin):

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.JMakeDepend -sourcepath src

JMakeDepend11 (JDK1.1 only)

Note that the version of JMakeDepend11 on the CD-ROM has been enhanced since the version described in the book. You can read about the details in the README file.

JMakeDepend11 depends on the Sun Collections classes. Synopsis:

java -classpath $CLASSPATH:$JARFILE:$COLLECTION com.macmillan.nmeyers.JMakeDepend11 [-noinner] [-sourcepath <path>] [<class files>]

For example (assuming class file names will be fed to stdin):

java -classpath $CLASSPATH:$JARFILE:$COLLECTION com.macmillan.nmeyers.JMakeDepend11 -sourcepath src

FileStatus

The FileStatus project is intended primarily for use as a utility class. You can read the javadoc documentation to learn about the API.

The class does include a simple main() method, allowing you to test the class. Synopsis:

LD_LIBRARY_PATH=$NATIVELIB java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.FileStatus <files>

For example:

LD_LIBRARY_PATH=$NATIVELIB java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.FileStatus *

XClipboard

The XClipboard project is intended primarily for use as a utility class. You can read the javadoc documentation to learn about the API.

The class does include a simple main() method, allowing you to test the class. Synopsis:

LD_LIBRARY_PATH=$NATIVELIB java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.XClipboard

The result of running the test is to dump the contents of the X CLIPBOARD, PRIMARY, SECONDARY, and CutBuffer0 buffers.

xwinwrap

The xwinwrap library must be pre-loaded when running an X application (such as Java AWT applications). For example:

LD_PRELOAD=$NATIVELIB/xwinwrap.so java ...

If you specify a visual, using the visual id values reported by the xdpyinfo utility, that visual will be used for the application:

LD_PRELOAD=$NATIVELIB/xwinwrap.so XWINWRAP_VISUALID=0x22 java ...

FontPerf (JDK1.2)

Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.FontPerf [-nodoublebuffer] <fontname> <columns> <rows> <repetitions>

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.FontPerf serif-plain-12 60 30 10

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.FontPerf -nodoublebuffer serif-plain-12 60 30 10

FontPerf (JDK1.1)

The FontPerf program is usable under JDK1.1, but includes a dependency on the Swing classes. Synopsis:

java -classpath $CLASSPATH:$JARFILE:$SWING com.macmillan.nmeyers.FontPerf [-nodoublebuffer] <fontname> <columns> <rows> <repetitions>

For example:

java -classpath $CLASSPATH:$JARFILE:$SWING com.macmillan.nmeyers.FontPerf serif-plain-12 60 30 10

java -classpath $CLASSPATH:$JARFILE:$SWING com.macmillan.nmeyers.FontPerf -nodoublebuffer serif-plain-12 60 30 10

memstress

This is just a native C program. Synopsis:

$NATIVELIB/memstress <#bits of address space> <#repetitions>

For example:

$NATIVELIB/memstress 24 5

BackingStore (JDK1.2 only)

You can read the javadoc documentation to learn about the API for the BackingStore class.

The CD-ROM also provides the four versions of the Spiral program used to demonstrate the performance effectiveness of backing store. Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral0 <width> <height>

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral1 <width> <height> <count> <delay in ms>

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral2 <width> <height> <count> <delay in ms>

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral3 <width> <height> <count> <delay in ms>

For example:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral1 300 300 100 100

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral2 300 300 100 100

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.Spiral3 300 300 100 100

PerfAnal (JDK1.2 only)

To generate the data to be analyzed by PerfAnal, you need to run a Java application using the hprof profiler, as described in Chapter 60. After collecting the data, run PerfAnal. Synopsis:

java -classpath $CLASSPATH:$JARFILE com.macmillan.nmeyers.PerfAnal [<tracefiles>]

If tracefiles are not specified, PerfAnal reads tracefile data from stdin.

Profiler (JDK1.2 only)

The Profiler native shared library is loaded using the java launcher's -Xrun command-line option. Synopsis:

LD_LIBRARY_PATH=$NATIVELIB java -green -XrunProfiler[:<options>] ...

For example:

LD_LIBRARY_PATH=$NATIVELIB java -green -XrunProfiler:file=profiledata.txt ...

To see the available options:

LD_LIBRARY_PATH=$NATIVELIB java -green -XrunProfiler:help

Inprise JBuilder

The CD-ROM includes a distribution of the Inprise JBuilder3 Foundation integrated development environment. That distribution is not reproduced on this site, but the product can be obtained from Inprise at http://www.inprise.com/jbuilder/foundation/download/linux.html.