main().
We'll conclude with some more discussion of the specifics of the implementation. This column teaches concepts and the applets don't really do anything useful other than serve as an instructional vehicle.
The following examples demonstrate the use of the serialization technology that has been included in JDK 1.0.2. An add-on package is required to run the following applets. The applets below were run with the JDK appletviewer on Windows 95 and Solaris. I was unable to find a browser manufacturer that clearly stated what version of the JDK they were running and decided that it was best to wait for Microsoft and Netscape to get up to speed with the up and coming JDK 1.1 release. If you have problems installing the serialization classes needed on your system try looking at this FAQ. The javaSoft team has also been nice enough to collect all the mail messages for those of you wishing to find quick answers to questions.
CLASSPATH environment variable to include the lib/rmi.zip file in the RMI directory.
CLASSPATH. Use the appletviewer or the Java virtual machine to run the applets below.
The following two applets save an object and retrieve some classes. Because they are writing to the disk you will have to
run these programs locally on your system. The ShowSavingAClass applet saves a String and a Date class to a disk file called SavedObject in the current directory. ShowReadingAClass reads the saved file SavedObject and recreates the classes contained in it. If your browser has RMI support then you can run the following two applets:
The programs require that a server program be running on the server so that an applet or Java application can communicate over the port to save objects.
The program WriteObjectsFromSocket reads an object from a client and saves it on the server in a fixed area. Here's the source. To create a file on a server that contains an instance of the object run the following:
java WriteObjectsFromSocket servername portnumber,
ShowSavingAClassNet. Here's the source. Don't forget to modify the HTML parameter tags if you host this applet on your local system.
The source code for ShowSavingAClassNet.java contains an example of designing applets that use the same source code for both so that users can start them with or without
the applet viewer.