Many of the examples rely on a package hierarchy which does not exist on the CDROM. You will need to construct this package hierarchy inside your CLASSPATH. One way to do this is to simply create a JNC directory inside your CLASSPATH. For instance, the path for the HttpdSimple example might look like this:
jdk1.1.4 -classes --JNC ---HttpdSimple.java ---HttpdSimpleTest.javaThis assumes that the jdk1.1.4/classes directory is in your CLASSPATH.
Almost all of the examples given in the book are inside the package JNC. This means that the .java file and the .class file MUST end up inside the directory JNC under your CLASSPATH if you intend to run the example using, say, the JDK.
After you have recompiled these classes you can simply run them using the JDK "java" command, the Java Runtime Environment, or your favorite IDE's java execution facility.
Once you've moved the files, you need to make a slight modification to the package and
import statements in the "WebDroneGroup.java" file. Change the package statement to
"package JNC.WDG;" and add an import line: "import JNC.*;". This indicates to the JDK
that all classes compiled from this code should be placed in the path
There are a few important things to note about javac:
If you can't get your IDE to open a particular project file, what you can
do is essentially recreate the project file in your IDE. From the list of native
files in the particular project's subdirectory, it should be fairly easy to
determine which files should go into the project. Also, the "Linking with the
Natives" chapter gives a great deal of detail about special native project settings
necessary for compiling and linking.
Q: How do I use "javac" from the JDK to compile .java files?
If you simply type "javac" and return at your command line (Win32 and Solaris),
javac should dump a list of options that it understands. Typically you use javac
like "javac MyClass.java".
If you have any questions about the operation of javac, look at the documentation
that came with the JDK or is available from the JavaSoft websites.
How do I use "java" from the JDK to run examples?
First off, note that you MUST follow the directions provided elsewhere in this FAQ on
how to compile the examples. Once you have compiled them under your CLASSPATH, then
you can run them using the JDK's "java" command. You can ONLY run classes which have
a "public static void main" method. Many of the examples provide a "FooTest" class
which is a class associated with class "Foo" that contains a main method. You can
then run the FooTest class, and thereby test the Foo class, by doing "java FooTest".
If this does not make sense, then read the JDK tools documentation that came with the
JDK or is available from the JavaSoft websites.
Q: Where is the "DeathStarPackage" package?
Q: Why do I sometimes I get a ClassNotFoundException for a class in
the "DeathStarPackage" package?
There are specific classes on the CDROM we absolutely know must be recompiled in order to
work correctly. These .class files contain references to an early development package
which no longer exists: the "DeathStarPackage" package. In the source code files,
this package has been replaced by the "JNC" package.
\src\ceCTBMac\ceCTBMac.class
\src\CESerialWin32\CESerialWin32.class
\src\cesersol\cesersol.class
\src\DNS\DNSTest.class
\src\FingerClient\FingerClientTest.class
\src\FunkyTerm\FunkyTerm.class
\src\icb\ICBMain.class
\src\NMEAStreamParser\NMEAStreamTest.class
\src\ScheduledEvent\ScheduledEvent.class
\src\SevenBitFilterInputStream\SevenBitFilterInputStream.class
\src\SimpleSocketClient\SimpleSocketClientTest.class
\src\StdioShell\StdioShell_Test.class
\src\WebDrone\WebDroneTest.class
If you delete these class files and then recompile, the examples should work smoothly.
Q: What is this "DeathStarPackage" file I see in some subdirectories?
A zero kB file named "DeathStarPackage" appears in certain subdirectories.
This are leftovers from alias files used on the MacOS during earlier development.
You can safely ignore these or delete them.
Q: What are these "Ws_ftp.log" files that appear on the CDROM?
The "Ws_ftp.log" files are leftovers from when files for the CDROM were
transferred via FTP-- you can ignore these or delete them.
Q: Who do I sometimes have trouble opening the native IDE project files with my
IDE (Borland C++, CodeWarrior, Cafe, etc.)?
Unfortunately, there are many versions of these platform-specific IDEs floating
around, and project files created with one may not be openable by another. We
sometimes have problems opening IDE project files with the same version of the
IDE as created the file in the first place.
Q: Why do I have problems using the ScheduledEvent class with
the ScheduledEventTest and SimpleWebDrone classes?
In ScheduledEvent, there are some methods with the word "Occurrence" in them.
These methods are spelled correctly. However, in the ScheduledEventTest,
SimpleWebDrone, and perhaps other classes, the spelling is incorrect ("occurence").
When you compile the examples, the compiler should complain that it can't find
a method with the word "occurence" in it. To fix this problem, simply fix the
spelling of the method name in the class you're trying to compile and it should work.
We'll be placing some examples with the correct spelling up on the JNC website shortly.
(Thanks to Alen Peacock for reporting this error.)
Q:On page 10 a method mark(index) is listed-- where can I find this?
This is an error. The correct method signature is mark(int readLimit) and a
full explanation of mark/reset used with input streams is given on page 32.
(Thanks to Laurence Vanhelsuwe for reporting this error.)
Q:On page 92 it says IP includes the concept of a port-- is this true?
This is an error. The IP protocol itself does not include the concept of a host
port. However, the two main IP-based protocols used in Java, UDP and TCP, do
use this concept.
(Thanks to Laurence Vanhelsuwe for reporting this error.)