eXtropia: the open web technology company
Technology | Support | Tutorials | Development | About Us | Users | Contact Us
Resources
 ::   Tutorials
 ::   Presentations
Perl & CGI tutorials
 ::   Intro to Perl/CGI and HTML Forms
 ::   Intro to Windows Perl
 ::   Intro to Perl 5
 ::   Intro to Perl
 ::   Intro to Perl Taint mode
 ::   Sherlock Holmes and the Case of the Broken CGI Script
 ::   Writing COM Components in Perl

Java tutorials
 ::   Intro to Java
 ::   Cross Browser Java

Misc technical tutorials
 ::   Intro to The Web Application Development Environment
 ::   Introduction to XML
 ::   Intro to Web Design
 ::   Intro to Web Security
 ::   Databases for Web Developers
 ::   UNIX for Web Developers
 ::   Intro to Adobe Photoshop
 ::   Web Programming 101
 ::   Introduction to Microsoft DNA

Misc non-technical tutorials
 ::   Misc Technopreneurship Docs
 ::   What is a Webmaster?
 ::   What is the open source business model?
 ::   Technical writing
 ::   Small and mid-sized businesses on the Web

Offsite tutorials
 ::   ISAPI Perl Primer
 ::   Serving up web server basics
 ::   Introduction to Java (Parts 1 and 2) in Slovak

 

Introduction to Web Programming
Building a Cab File  
  • After you have created your ZIP archive, you can then create a CAB (CABinet) file that will contain your compressed and archived applet for Microsoft's Internet Explorer users. Building CAB files is a little less user-friendly than building ZIP files since there is graphical interface like WinZip for creating CAB files.

  • Instead you will have to use the command line interface provided by CABARC. CABARC is a compression/archiving program distributed with Microsoft's SDK which should be located either in the "bin" directory under your main SDK directory or the "bin/packsign" directory.

  • CABARC follows the generic format:

    CABARC [options] command cabfile [@list] [files] [dest_dir]
    

  • Options and Commands are summarized in the following table

Parameter Commend
L Used to list the contents of a cabinet.
N Used to create a cabinet file.
X Used to extract single or multiple files from the cabinet.
Options
-c Confirms the files to be operated upon
-o Overwrites without confirming when extracting
-m Sets the type of compression to use to LZX:<15..21>, MSZIP, or NONE. The default is MSZIP
-p Used to preserve path names
-P Used to strip a specified prefix from files when they are added
-r Used to recurse into subdirectories when adding files
-s Used to reserve space in the cabinet for signing. For example, -s 6144 reserves 6k.
-I Used to set the ID of the cabinet when creating a cabinet. The default is 0.

Cabarc Commands

  • As you can see, there are several commands that CABARC supports. You can list the files in cabinets, add files to cabinets, and remove file from cabinets.

  • For the most part, you will be primarily interested in creating CAB files. Thus, it is the "N" command that you will use most often. For example, the following CABARC command would create a CAB file called "MyApplet.cab" that would contain all of the class files in the current directory.

    cabarc N MyApplet.cab *class
    

  • CABARC also allows you to list the files in a current cabinet. In this case, you will use the "l" command as follows:

    cabarc L MyApplet.cab *class
    

  • The "L" command returns information about the size of each file in the cabinet, the dates and times each was added, as well as the attributes of each file

  • Finally, CABARC allows you to selectively remove files from within a cabinet file using the "X" command. For example, to remove the SupportClass.class file from the example above, we would use the following syntax:

    cabarc X MyApplet.cab SupportClass.class
    

  • Notice that when extracting files, the default behavior is for CABARC to ask you if you would like to overwrite existing files if they have the same name as those being extracted.

CABARC Options

  • Of course, it is most likely that you will specify options when performing actions with CABARC. For example, consider the MyApplet example we have been using so far in this chapter. The MyApplet program actually contains several files and several directories. Unfortunately, as shown above, if you simply use the "N" option to create your archive, you will not be able to add all these files and directories in one simple line. You would have to add each directory and file separately.

  • Fortunately, CABARC provides the -r option to add files to a CAB archive recursively. Thus, to create a functional CAB archive for our applet, we would want to use something along the lines of

    cabarc -r N MyApplet.cab *
    

  • As you can see, the -r option will add all of the files and all of the subdirectories necessary for our cabinet file. However, the -r option will add files that are not necessary such as the .txt , .java and .html files. In order to make your CAB archive as small as possible, you will want to only add the necessary files.

  • To do so, you can specify the list of files to add using something like the following:

    cabarc -r N MyApplet.cab *class *.jpg, *.gif
    

  • In this case, you will only get files with the specified extensions.

Referencing your Cabinet

  • However, you are not quite done yet. Once you create your cabinet, you must then upload it to your web server and make it available to web browsers using the CABBASE parameter as follows:

    <APPLET CODE = "MyApplet.class" ARCHIVE = "MyApplet.zip"
            WIDTH = "140" HEIGHT = "140">
    <PARAM NAME = "cabbase" VALUE = "MyApplet.cab">
    </APPLET>
    

  • In this case, Internet Explorer will parse the parameter and access the cabinet file.

Previous Page | Next Page