Currently, both Sun and Microsoft have bridging tools that are freely available for download: the Packager application from Sun and javareg from Microsoft (see Resources). Which one you choose will depend a lot on your personal tastes. Each has its strong and weak points. In general, users of your bridged JavaBeans won't see much difference between the two solutions. Both solutions utilize a Java virtual machine (VM) that is loaded as a dynamically linked library (DLL) into the client application or development tool. It's important to note that both solutions load only one instance of the VM per client. This allows an application to "connect" multiple ActiveX controls to each other, and know that that their underlying JavaBean instances are running in a shared VM.
Unfortunately, neither of the toolsets earns points for its robustness. Both do a rather poor job of helping you diagnose problems with your controls. However, I did find Sun's BeanBox testing tool helpful in validating JavaBeans prior to running either bridging tool. In addition, both tools suffer from a lack of good documentation (as if anything ever comes with good documentation, right?) Fortunately, Sun provides reasonably responsive e-mail support for its JavaBeans Bridge. While Microsoft's free support is limited, the Java-COM list server is a good place to look for answers specific to tools. (See Resources for information on how to access these support services.)
The first tool we'll examine is the Packager application, which comes as part of Sun's JavaBeans Bridge for ActiveX. Packager allows you to:
We'll examine each of these aspects in the following discussion.
Packager is a Java application that has both graphical and command-line interfaces. To use it, you place your JavaBean(s) in a jar file along with any supporting code or resources. Note that your beans must belong to a package other than the default package, otherwise the Packager will crash, leaving you with nothing but a cryptic error message about string parsing.
Packager's GUI guides you through the process of bridging your JavaBeans. You first select the jar file and JavaBean you wish to bridge, as well as the name for the ActiveX control and destination directory for the generated files. One nice feature is Packager's ability to "uncrack" Java events so they're delivered as their component parts -- much like events from "native" ActiveX controls -- rather than single event objects. The example below shows a typical Java event class: