How To Implement Dependencies When Building Distribution Units Manually

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 <DEPENDENCY> 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:

  1. 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.");}}
  2. 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
  3. Extract the base cabinet file with a cabarc X command.

    cabarc X cab1.cab *.osd
  4. 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"?><SOFTPKG NAME="BaseCab" VERSION="1,1,1,1"><!-- created by DUBuild version 5.00.3167 -->    <TITLE>BaseCab</TITLE>    <MSICD::JAVA>        <PACKAGE NAME="basecab" VERSION="1,1,1,1">            <IMPLEMENTATION/>        </PACKAGE>    </MSICD::JAVA></SOFTPKG>
  5. 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>
  6. Rebuild the .cab file to include the new .osd file.

    cabarc -p -r N cab1.cab *Applet*.class BaseCab.osd
    Don't forget to sign your cab files.


    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
  7. Test the new cabinet file with Internet Explorer.
    <HTML><APPLETcode="basecab.CabApplet1"name="CabApplet1"width=320height=200><PARAM NAME="useslibrary" VALUE="BaseCab"><PARAM NAME="useslibrarycodebase" VALUE="cab1.cab"><PARAM NAME="useslibraryversion" VALUE="1,1,1,1"></APPLET></HTML>

REFERENCES

For additional information about relative URL's and DU dependencies, click the article number below
to view the article in the Microsoft Knowledge Base:

247369 FIX: Relative URLs Don't Work for Distribution Unit Dependencies
For additional information on how to package distribution unit dependencies using Visual J++, click the article number below
to view the article in the Microsoft Knowledge Base:

246492 How To Use Visual J++ 6.0 to Make Dependency Distribution Units
For more information on Distribution Units (DU), see the document, "Creating and Using Distribution Units," on the following Microsoft Web page:
Svojstva

ID članka: 242970 - posljednja izmjena: 14. velj 2017. - verzija: 1

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

Povratne informacije