Copyright (c) 2001, Junzo SATO. All rights reserved.

Serialization and Deserialization of JavaBeans

Serializable JavaBeans objects are handled.

Junzo SATO

Aug 18th 2001

Installing J/Link

J/Link Mathmatica package is loaded.

[Graphics:Images/tinybean_gr_1.gif]

InstallJava[ ] setups J/Link environment so that the Mathmatica can use Java. Options of InstallJava[ ] varies depending on which machine and operating system a user is using.

[Graphics:Images/tinybean_gr_2.gif]
[Graphics:Images/tinybean_gr_3.gif]
[Graphics:Images/tinybean_gr_4.gif]
[Graphics:Images/tinybean_gr_5.gif]

JavaBeans  Object

Definition of a JavaBeans is stored in MrBeans.jar in the system. The TinyBean has one property "count" as int.

[Graphics:Images/tinybean_gr_6.gif]
[Graphics:Images/tinybean_gr_7.gif]

By default the value of the count is 100.

[Graphics:Images/tinybean_gr_8.gif]
[Graphics:Images/tinybean_gr_9.gif]
[Graphics:Images/tinybean_gr_10.gif]
[Graphics:Images/tinybean_gr_11.gif]

The value is changed to 200.

[Graphics:Images/tinybean_gr_12.gif]
[Graphics:Images/tinybean_gr_13.gif]
[Graphics:Images/tinybean_gr_14.gif]

Loading Serialized Object In The File

The serialized object of the JavaBeans is stored in tiny.ser file, where the value of the count property has been set to 4321.

[Graphics:Images/tinybean_gr_15.gif]
[Graphics:Images/tinybean_gr_16.gif]
[Graphics:Images/tinybean_gr_17.gif]
[Graphics:Images/tinybean_gr_18.gif]

The serialized object in the file is deserialized.

[Graphics:Images/tinybean_gr_19.gif]
[Graphics:Images/tinybean_gr_20.gif]
[Graphics:Images/tinybean_gr_21.gif]
[Graphics:Images/tinybean_gr_22.gif]
[Graphics:Images/tinybean_gr_23.gif]
[Graphics:Images/tinybean_gr_24.gif]
[Graphics:Images/tinybean_gr_25.gif]
[Graphics:Images/tinybean_gr_26.gif]

Saving JavaBeans Into The File

The obj which has new value is serialized into a new file.

[Graphics:Images/tinybean_gr_27.gif]
[Graphics:Images/tinybean_gr_28.gif]
[Graphics:Images/tinybean_gr_29.gif]
[Graphics:Images/tinybean_gr_30.gif]
[Graphics:Images/tinybean_gr_31.gif]
[Graphics:Images/tinybean_gr_32.gif]

Checking New Beans

We can easily check the value of new beans stored in the new file by loading it again.

[Graphics:Images/tinybean_gr_33.gif]
[Graphics:Images/tinybean_gr_34.gif]

Removing J/Link

[Graphics:Images/tinybean_gr_35.gif]
[Graphics:Images/tinybean_gr_36.gif]
[Graphics:Images/tinybean_gr_37.gif]

Reference

[1] Japanese translation of the following book:
Joseph O'Neil, "JavaBeans Programming from the Ground Up", McGraw-Hill, 1998


Converted by Mathematica      August 18, 2001