Crash Course in Java

I was helping on writing a Unix book for Solaris this spring. My chapters were about compiling, debugging, makefiles and SCCS. I was trying to convince the main author that we should do a chapter on Java rather than C. To convince myself, I took his tabs.c example and tried to translate it to Java. I found it an interesting exercise, but decided it was sort of a crude way to learn Java. That is, it wasn't object oriented.

Later I was talking to another professor who pointed out that most of the students who were programming in C++ were not doing object oriented designs, but rather writing C programs using streams instead of printf. So I changed my mind and decided it would be an acceptable first shot at least to point out the differences between C and Java.

The complete collection of files are in this directory. The list below goes over the files one at a time. The filenames do not have "internet" extensions. You may want to download a gzip tar file to your local machine dir2.tar.gz.


In both the math and computer science network in my home directory (~bellenot) there is a directory jdk1.2beta4 which contains Java1.2 (4th beta) and Java3d 1.1 (first beta). Inside the jdk1.2beta4 is a directory java3d which contains only the docs and examples for java3d. Inside the jdk1.2beta4 directory is the visad directory which contains VisAd.

To use these files instead of the installed java you need to add the directory ~bellenot/jdk1.2beta4/bin to your path. Csh or tcsh users do this with the command set path=(~bellenot/jdk1.2beta4/bin $path). Ksh, bash do this with the command PATH=~bellenot/jdk1.2beta4/bin:$PATH and in both cases be careful not to introduce spaces around the '='.

The step above is enough to run java code compiled in your home directory but if you want to run the visad examples in visad/examples you will need to set a CLASSPATH environment variable to ~bellenot/jdk1.2beta4:. Csh does setenv CLASSPATH ~bellenot/jdk1.2beta4:. and ksh does export CLASSPATH=~bellenot/jdk1.2beta4:. (The last . is part of the expression). Try `java DisplayTest 0' in visad/examples.