Serialized Applets
Home ] Up ] Object Streams and Serialization ] Serializing Families of Classes ] Serialization and Class Versioning ] Custom Serialization and Security ] [ Serialized Applets ] Advanced Serialization ]

 

 

One potentially useful application of serialization is to be able to load applets directly from a file containing the applet in its serialized form.

For this purpose, a new attribute of the <APPLET> tag was introduced: OBJECT. This is intended to be used in place of the CODE attribute:

<applet width=415 height=150 object="SerializedApplet.ser">
</applet>

This should cause the browser to create the applet by downloading the specified file (SerializedApplet.ser in the above example), and then deserializing it. The applet can be quite complex, with many GUI components; however, it cannot contain non-serializable classes unless serialization on those components is disabled. The GUI can have been initialized earlier before it was serialized out; once deserialized back in by the browser, the applet will resume its initialized state without further work.

You don't even have to serialize your applet by programming it. You can use appletviewer. Here's what you do:

  • Develop your applet.
  • Run it in appletviewer, which will load the applet in the usual way, and run the init() and start() methods.
  • Use Applet->Save... menu item to serialize the applet to a file (conventionally a .ser file)
  • Deploy your converted HTML file and .ser file to your web site.

Unfortunately, I have never been able to get this to work in any current browser.

 

The page was last updated February 19, 2008