Creating and Using Digitally Signed CAB Files

This article has four sections:
To see: See the

To see the sample as a standalone


Overview of the sample

The CabAndSign sample demonstrates how the Cabinet Development Kit and the Code Sign Kit are used to create signed cabinet (CAB) files. Signed CAB files are required if a Java applet is to use COM components.

About the server

BEEPER.DLL is a simple Automation server. It is one of the samples from the ActiveX Template Library (ATL). You can download ATL from the Web (
www.microsoft.com/visualc/v42/atl/).

Beeper has two methods and one property of interest.

About the sample

javabeep creates a Beeper object (COM component). It calls the Beep method of Beeper in response to mouseDown events. If the call succeeds, Beeper plays the default system sound. javabeep then calls getItem to get a series of strings from Beeper. It displays the set of strings at the location of the mouseDown. If the call fails (as it will every sixth time), no system sound occurs. In response, javabeep places an error message at the location of the mouseDown event.

See javabeep.start for creating the beeper COM component. See javabeep.mouseDown for the calls to the beeper COM component and handling the failure of the call to Beep. Use ClassView to help you find these methods.

About security

COM components can access any system resources. As such, they are both very powerful and potentially very dangerous. In the Java virtual machine (VM) in Microsoft® Internet Explorer 3.0 only trusted class files can use COM components. Class files from digitally signed CAB files are trusted.

If the HTML file is run from Microsoft Developer Studio, the class files are also trusted. This can be very helpful during applet development. However, to deliver your applet to other users, you must put it in a signed CAB file.

The code for the applet itself is taken from the JavaBeep sample. For more information on the Java code and the server, see the JavaBeep sample.

Return to the top of this article.


How to use this sample

To run the CabAndSign sample:

  1. Register BEEPER.DLL, the COM component for this sample.
    See
    Registering a COM Component.
  2. Create a Java interface for the COM component.
    See Creating a Java Interface for a COM component.
  3. In Explorer, double-click the WVTSTON.REG file to enable test certificates on this machine.
  4. In Explorer, double-click the JAVABEEP.HTML file to open it.
To create your own CAB file and sign it:
  1. Create a CAB file with your CLASS files.
    See Making Cabinets.
  2. Create a test certificate (this needs to be done only once).
    See Creating a Test Certificate.
  3. Sign the CAB file with your certificate.
    See Signing a Program File.
To use the .CLASS files from a CAB file:
For example:
     <param name="cabbase" value="firstcab.cab">
Return to the top of this article.

Troubleshooting this sample

If you did not see the certificate:

If you get the error message ClassNotFoundException:

If you get the error message UnsatisfiedLinkError:

Return to the top of this article.

Files in this sample

This sample includes the following files.

Primary files:

Project files: Support files: Return to the
top of this article.