Last year's book-publishing love affair with the Internet has already
morphed into this year's doting on Java, the programming environment from
Sun Microsystems. Although there are numerous Java-related books in the
works, Hooked on Java, by Java development team members Arthur van
Hoff, Sami Shaio, and Orca Starbuck, is one of the first. For $29.95 you
get the book and a CD-ROM containing documentation, sample applets, and
development tools in both Sun Solaris 2.x, Windows 95, and Windows NT format.
Both a Java compiler and an applet viewer are included and neither an Internet
connection nor a browser is needed to explore the language or the sample
applets on the CD. You do, however, need Netscape Navigator 2.0 to run the
Java-powered Web pages.
The book, which consists of six chapters and numerous appendices, is intended
for anyone involved with the creation of Web pages and/or interested in
learning the basics of Java applets. Chapters 3 and 4 constitute a cookbook
for integrating the applets into Web pages. All the applets covered are
included on the CD along with an example Web page using the applet. You
should be familiar with HTML, but progression beyond the HTML bunny slopes
will be needed to creatively apply much of the information. Chapters 5 and
6 cover basic Java syntax and building a Java applet from scratch. Here,
the primitive state of Java and the lack of development tools become apparent.
The authors statement in chapter 5 (repeated in chapter 6) that "You
should know a little about programming to get the most out of this chapter"
is an understatement to say the least.
In the cookbook section, the authors thoroughly describe the applets and
how to incorporate them into Web pages. The reading is easy and the discussion
on the Applet tag in chapter 3 is excellent. After a few examples, however,
you'll likely want to skip to the CD and run the applets from the menu and
use this part of the text for reference. In looking over the Applet tag
examples, I did notice that quotes are used inconsistently. In one instance,
the code filename is quoted, in the next it isn't. Knowing that quotes are
only required if a string contains a blank is helpful when you are getting
started. Rather than cutting and pasting from the examples, I wrote my own
entry from the Applet Tag Definition in Appendix G. Nothing in the definition
indicated to me that = signs are needed, but they are and the
examples have them. DOS readers would also benefit from a discussion about
the use of \ versus / in paths.
JAVASPEC.PS
file in the Psfiles.zip archive.javac uiapplet.java
instead of javac UIApplet.java will cause the compiler to bomb
with the message Warning! Public class UIApplet must be defined in a
file UIApplet.java. This is definitely not what a DOS-oriented person
would expect, and some warning is needed.\Win95\index.html
file does not exist and the subdirectories in the Solaris directory have
been compressed into zip files in the Win95 directory. To run anything you
must first install the files on your hard disk using an unzip program that
can handle long file names. I first unzipped it using OS/2 and copied the
files to Win95 over my peer network. Since then, I have acquired WinZip
6 and reinstalled everything. It works fine.java.awt.image.html
and java.awt.Image.html. If you have Navigator 2.0 installed
you can view any of the HTML pages by dragging it and dropping it on the
Netscape icon. I should say you can view any of them except the java
.awt.Image.html. Since the Windows 95 file system is not case sensitive
it always finds the first one. java.awt.image.html documents
the package java.awt.image, while java.awt.Image.html
documents the class java.awt.image. No matter what you do it will be wrong.
I used a different name for the first file. It ends up as an orphan, but
it is accessible if you ever need it and can remember what you named it.
Once installed, all the applets can be run in Navigator 2.0 by loading one
of the menu files /hooked/book/building.html or /hooked/book/cool-applets.html
and selecting the desired applet.setBackground() and a setForeground()
method to set colors. I could set any color I wished and recompile the applet,
but it always displayed black on gray. This was true whether I used the
Applet viewer or Netscape.setForeground()
and setBackground() methods and essentially had to scan all
of the class methods. When you do locate it, you wonder why you bothered
because it is typical UNIX man-page jargon. If you prefer hard copy, you
can print it from the Postscript files.