Note: You can view the full content of our pages on any browser or Internet device. However, our pages look best in browsers that support Web Standards.

Java Number Cruncher: The Java Programmer's Guide to Numerical Computing

Downloads

Below are instructions for installing, compiling, and running the programs from Java Number Cruncher: The Java Programmer's Guide to Numerical Computing.

Install

Download the file that corresponds to your platform:

On Windows, extract nc.jar from nc.jar.zip with any ZIP utility, such as WinZip. On Linux, extract nc.jar from nc.jar.gz with the command

gunzip nc.jar.gz

(On Solaris, download nc.jar.zip, rename it nc.jar.gz, and then execute the above command.)

Then, on either platform, expand nc.jar with the Java jar utility:

jar -xvf nc.jar

This assumes that the bin directory of your JDK installation is in your CLASSPATH, for example, /usr/java/jdk1.3.1_05/bin. Use JDK 1.3.x or later.

Expanding the archive file will create, in your current directory, the directory nc, which itself will contain directories classes, html, and source.

Directory nc will also contain a number of scripts in the form of bat files (for Windows) and sh files (for Linux). On Linux, you must make the script files executable:

chmod u+x nc/*.sh

Directory nc/source is the base directory of all the Java programs featured in the book (their package hierarchy is rooted here). By compiling these source files, you will be able to run both the text-only programs and the interactive graphical programs. You will also be able to create the applets.

Directory nc/classes will be the root of the compiled class files.

Directory nc/html contains a subdirectory nc that contains the HTML files and the GIF files (in directory nc/html/nc/images) that you will need if you want to create a local website to run all the applets.

SET UP YOUR ENVIRONMENT

Note: I recommend using JDK 1.3.x to compile the Java source files if you want to run the applets using the built-in JVMs in the Microsoft Internet Explorer 5.x or 6.x browser, or the Netscape 4.x or 6.x browser. If you compile with JDK 1.4.x, you will need to download from Sun and install new JVM plug-ins into your browsers to run the applets. Some of the applets currently do not work well with the plug-ins.

You can create several jar files that will be used by the applets. To make these jar files available to your local website, you should place them in the nc directory of your web server's document root directory (see LOCAL WEBSITE, below).

On Windows, first edit the script file setjava.bat to set values for several environment variables:

Variable Description
javahome the base directory of your chosen JVM installation
java the Java program executor
javac the Java compiler
jardest the destination directory of the jar files; as described below in LOCAL WEBSITE, this should be the nc directory of your web server's document root
jar the jar utility

Then execute setjava.bat.

On Linux, you'll need to edit your command shell's initialization file, such as ~/.bashrc, to set the corresponding environment variables. Insert the following statements (modify them as necessary):

    JAVA_HOME=/usr/java/jdk1.3.1_05
    JAVA=$JAVA_HOME/bin/java
    JAVAC=$JAVA_HOME/bin/javac
    export JAVA_HOME JAVA JAVAC
    
    JAR_DEST=/var/www/html/nc
    JAR=$JAVA_HOME/bin/jar
    export JAR_DEST JAR

Then execute the source command on the initialization file, for example,

source ~/.bashrc

Compile

Note: Your current directory should be nc when executing these scripts.

On Windows, first execute the script complibs.bat. On Linux, first execute the script complibs.sh. This will compile the utility packages (graphutils, mathutils, etc.).

Then compile all the programs. On Windows, execute the script comprogs.bat. On Linux, execute the script comprogs.sh.

Run

Note: Your current directory should be nc when executing these scripts.

On Windows, execute a program via its run script, for example, run14-1.bat. Scripts that execute the interactive graphical demo programs have a 'd' in their names, such as run14-1d.bat.

On Linux, execute a program via its run script, for example, run14-1.sh. Scripts that execute the interactive graphical demo programs have a 'd' in their names, such as run14-1d.sh.

As explained in the book, Programs 7-1, 8-1, and 13-3 will each require a single command-line argument.

Local Website

Note: Your current directory should be nc when executing these scripts.

In order to run a local website using the HTML files, you must have a web server running, such as Apache. The default URL for this website is

http://localhost/nc/

where nc is a directory in your web server's document root directory. For example, if you use the Apache web server, on Windows, it could be

c:\apache\apache\htdocs\nc

and on Linux, it could be

/var/www/html/nc

See the documentation for your web server for the location of its document root.

Copy all the contents of nc/html/nc into the nc directory of the document root.

You will need to create the jar files that will be served to the applets. The scripts will create the jar files and, as determined by your environment setup, put them into jardest (Windows) or JAR_DEST (Linux). This destination should be the nc directory of the document root.

On Windows, execute the script jarlibs.bat to build the jar files for the utility packages. On Linux, execute the script jarlibs.sh.

Then, on Windows, execute the script jarprogs.bat to build the jar files for each applet. On Linux, execute the script jarprogs.sh.

Note to Macintosh Users

These programs will compile and run on the Macintosh. However, many of the graphical demos rely on doing "xor" painting to accomplish their animation effects, an operation which unfortunately does not seem to work very well on the Mac with Java.

Disclaimer

I wrote all these programs strictly as illustrative examples for my book. You're free to use the source code any way you like, but bear in mind that this is NOT fully tested, commercial-quality code. Neither Prentice Hall PTR nor I can be responsible for anything bad that may happen if you use these programs.

Note: These instructions were last updated November 10, 2002. Send e-mail to ron@apropos-logic.com if there are any problems.