Microsoft KB Archive/242970

= How To Implement Dependencies When Building Distribution Units Manually =

Article ID: 242970

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft Software Development Kit for Java 3.2
 * Microsoft Java Virtual Machine

-



This article was previously published under Q242970



SUMMARY
This article explains how to use the tools in the Software Development Kit for Java to build Distribution Units (DU) that have dependencies. This article assumes some knowledge of DUs, the software distribution tools found in the SDK and the Open Software Description specification, otherwise known as OSD.



MORE INFORMATION
A dependency in code download is a software distribution unit on which the one you are making is dependent. If the dependency unit is not installed on the target computer, the software you are distributing will not run. Hence, you need to include something in your DU that tells the browser to check to see if any software units, on which your current code depends, are in fact installed--if they are not, then something to instruct the browser to install them. The Visual J++ IDE includes support for dependencies, but the SDK for Java tool DUBUILD does not.

When you run the command-line tool Dubuild.exe, one of the things it does is generate an XML-based .osd file, which is sometimes called a manifest. OSD stands for Open Software Description and is a specification for standardizing the code-download process. The XML tags in this OSD file are what tells Internet Explorer how to install the software package contained in the cabinet file that it just downloaded. The  tag is the one that tells the browser on what code the DU is dependent and where to find it.

Here are the steps to create a Dependency Unit for the DU:   Compile the following Java code. Make sure you build the dependcab package first, since this is imported in the basecab package: package basecab;

import java.applet.*; import dependcab.*;

public class CabApplet1 extends Applet {   public void init {       try {           add(new java.awt.Label("This is the applet.")); NeededClass nc = new NeededClass; nc.testMethod; } catch (Exception ex) {           ex.printStackTrace; }   } }

package dependcab;

public class NeededClass {   public void testMethod {       System.out.println("testMethod called."); } }                     Create the DUs using the DUBUILD utility. Make sure you have the path set to sdk32\bin folder when using this utility: dubuild cab1.cab. /D "BaseCab" /I *Applet*.class /V 1,1,1,1 dubuild cab2.cab. /D "DependCab" /I *Needed*.class /V 1,1,1,1   Extract the base cabinet file with a cabarc X command. cabarc X cab1.cab *.osd   Open up the BaseCab.osd file that DUBUILD just generated. <?XML version="1.0"?> <!DOCTYPE SOFTPKG SYSTEM "http://www.microsoft.com/standards/osd/osd.dtd"> <?XML::namespace href="http://www.microsoft.com/standards/osd/msicd.dtd" as="MSICD"?> 

BaseCab</TITLE> <MSICD::JAVA> <PACKAGE NAME="basecab" VERSION="1,1,1,1"> <IMPLEMENTATION/> </PACKAGE> </MSICD::JAVA> </SOFTPKG> </li>  Edit the file to include the appropriate dependency tags. Place the dependency tag pair on the same hierarchical level and next to the MSICD::JAVA tag pair. (Note that an absolute URL is required in the CodeBase tag. For more information, see the references section at the bottom of this article.) <DEPENDENCY ACTION="install"> <SOFTPKG NAME="DependCab" VERSION="1,1,1,1"> <TITLE>DependCab</TITLE> <IMPLEMENTATION> <CodeBase HREF="http://Absolute_URL_to_cab2.cab"/> </IMPLEMENTATION> </SOFTPKG> </DEPENDENCY> </li>  Rebuild the .cab file to include the new .osd file. <pre class="fixed_text">cabarc -p -r N cab1.cab *Applet*.class BaseCab.osd Don't forget to sign your cab files. <pre class="fixed_text">setreg 1 true makecert -sk MyKeyName -n "CN=My Publisher Name" MyTestCert.cer cert2spc MyTestCert.cer MyTestCert.spc signcode -j javasign.dll -jp LOW -spc MyTestCert.spc -k MyKeyName cab1.cab signcode -j javasign.dll -jp LOW -spc MyTestCert.spc -k MyKeyName cab2.cab </li>  Test the new cabinet file with Internet Explorer. <HTML> <APPLET code="basecab.CabApplet1" name="CabApplet1" width=320 height=200>

<PARAM NAME="useslibrary" VALUE="BaseCab"> <PARAM NAME="useslibrarycodebase" VALUE="cab1.cab"> <PARAM NAME="useslibraryversion" VALUE="1,1,1,1"> </APPLET> </HTML>

</li></ol>

<div class="references_section">