<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="FeedCreator 1.7.2" -->
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
    <channel>
        <atom:link href="http://www.rkgenwa.yolasite.com/java-notesss.rss" rel="self" type="application/rss+xml" />
        <title>java-notesss</title>
        <description>java-notesss</description>
        <link>http://www.rkgenwa.yolasite.com/java-notesss.php</link>
        <lastBuildDate>Sat, 06 Jun 2026 04:20:27 +0100</lastBuildDate>
        <generator>FeedCreator 1.7.2</generator>
        <item>
            <title>java</title>
            <link>http://www.rkgenwa.yolasite.com/java-notesss/java</link>
            <description>&lt;!--[if !mso]&gt;

&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapedefaults v:ext=&quot;edit&quot; spidmax=&quot;1028&quot;/&gt;
&lt;/xml&gt;&lt;![endif]--&gt;&lt;!--[if gte mso 9]&gt;&lt;xml&gt;
 &lt;o:shapelayout v:ext=&quot;edit&quot;&gt;
  &lt;o:idmap v:ext=&quot;edit&quot; data=&quot;1&quot;/&gt;
 &lt;/o:shapelayout&gt;&lt;/xml&gt;&lt;![endif]--&gt;

&lt;h1&gt;Packaging Programs in JAR Files&lt;/h1&gt;

&lt;p&gt;The Java™ Archive (JAR) file format enables you to bundle
multiple files into a single archive file. Typically a &lt;b style=&quot;mso-bidi-font-weight:
normal&quot;&gt;JAR file contains the &lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;class files&lt;/i&gt;&lt;/b&gt;
and auxiliary resources associated with &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;applets and applications.&lt;/i&gt;&lt;/b&gt; &lt;/p&gt;

&lt;p&gt;The JAR file format provides many benefits: &lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Security&lt;/em&gt;: You can
     digitally sign the contents of a JAR file. Users who recognize your
     signature can then optionally grant your software security privileges it
     wouldn't otherwise have. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Decreased download time&lt;/em&gt;:
     If your applet is bundled in a JAR file, the applet's class files and
     associated resources can be downloaded to a browser in a single HTTP
     transaction without the need for opening a new connection for each file. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Compression&lt;/em&gt;: The JAR
     format allows you to compress your files for efficient storage. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;span style=&quot;mso-ignore:
     vglayout;position:absolute;z-index:1;left:0px;margin-left:-13px;
     margin-top:3px;width:27px;height:30px&quot;&gt;&lt;img src=&quot;file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image001.gif&quot; height=&quot;30&quot; width=&quot;27&quot;&gt;&lt;/span&gt;&lt;i&gt;&lt;em&gt;Packaging for extensions&lt;/em&gt;&lt;/i&gt;:
     The extensions framework provides a means by which you can add
     functionality to the Java core platform, and the JAR file format defines
     the packaging for extensions. &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;&lt;span style=&quot;font-size:15.0pt;
     mso-bidi-font-size:12.0pt&quot;&gt;Java 3D™&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style=&quot;font-size:
     15.0pt;mso-bidi-font-size:12.0pt&quot;&gt; &lt;/span&gt;and &lt;b style=&quot;mso-bidi-font-weight:
     normal&quot;&gt;&lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;&lt;span style=&quot;font-size:15.0pt;
     mso-bidi-font-size:12.0pt&quot;&gt;JavaMail™&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; are examples of
     extensions developed by Sun™. By using the &lt;b style=&quot;mso-bidi-font-weight:
     normal&quot;&gt;&lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;JAR &lt;/i&gt;&lt;/b&gt;file format, you
     can turn your software into extensions as well. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Package Sealing&lt;/em&gt;:
     Packages stored in JAR files can be optionally sealed so that the package
     can enforce version consistency. Sealing a package within a JAR file means
     that all classes defined in that package must be found in the same JAR
     file. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Package Versioning&lt;/em&gt;:
     A JAR file can hold data about the files it contains, such as vendor and
     version information. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l2 level1 lfo1;tab-stops:list .5in&quot;&gt;&lt;em&gt;Portability&lt;/em&gt;: The
     mechanism for handling JAR files is a standard part of the Java platform's
     core API. &lt;/li&gt;&lt;/ul&gt;

&lt;h1&gt;Using JAR Files&lt;/h1&gt;

&lt;p&gt;JAR files are packaged with the ZIP file format, so you can
use them for tasks such as &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:14.0pt;mso-bidi-font-size:12.0pt&quot;&gt;lossless data compression,
archiving, decompression, and archive unpacking&lt;/span&gt;&lt;/b&gt;. These tasks are
among the most common uses of JAR files, and you can realize many JAR file
benefits using only these basic features. &lt;/p&gt;

&lt;p&gt;Even if you want to take advantage of advanced functionality provided by the
JAR file format such as &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:13.0pt;mso-bidi-font-size:12.0pt&quot;&gt;electronic signing,&lt;/span&gt;&lt;/b&gt;
you'll first need to become familiar with the fundamental operations. &lt;/p&gt;

&lt;p&gt;To perform basic tasks with JAR files, you use the Java Archive Tool
provided as part of the Java Development Kit. Because the Java Archive tool is
invoked by using the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar&lt;/span&gt;&lt;/tt&gt;
command, this tutorial refers to it as 'the Jar tool'. &lt;/p&gt;

&lt;p&gt;As a synopsis and preview of some of the topics to be covered in this
section, the following table summarizes common JAR file operations: &lt;/p&gt;

&lt;table class=&quot;MsoNormalTable&quot; style=&quot;mso-cellspacing:1.5pt;
 mso-padding-alt:3.75pt 3.75pt 3.75pt 3.75pt&quot; border=&quot;1&quot; cellpadding=&quot;0&quot;&gt;
 &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;
  &lt;td colspan=&quot;2&quot; style=&quot;border:none;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;strong&gt;Common JAR
  file operations &lt;/strong&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;b&gt;Operation&lt;/b&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;b&gt;Command&lt;/b&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:2&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To create a JAR file&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar cf &lt;i&gt;jar-file
  input-file(s)&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:3&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To view the contents of a JAR file&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar tf &lt;i&gt;jar-file&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:4&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To extract the contents of a JAR file&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar xf &lt;i&gt;jar-file&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:5&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To extract specific files from a JAR file&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar xf &lt;i&gt;jar-file
  archived-file(s)&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:6&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To run an application packaged as a JAR file (requires the
  &lt;tt&gt;&lt;u&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;Main-class&lt;/span&gt;&lt;/u&gt;&lt;/tt&gt; manifest
  header)&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;java -jar &lt;i&gt;app.jar&lt;/i&gt;&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:7;mso-yfti-lastrow:yes&quot;&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;
  &lt;p&gt;To invoke an applet packaged as a JAR file&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:3.75pt 3.75pt 3.75pt 3.75pt&quot;&gt;&lt;pre&gt;&amp;lt;applet code=&lt;em&gt;&lt;span style=&quot;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt;AppletClassName.class&lt;/span&gt;&lt;/em&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;archive=&quot;&lt;em&gt;&lt;span style=&quot;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt;JarFileName.jar&lt;/span&gt;&lt;/em&gt;&quot;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;width=&lt;em&gt;&lt;span style=&quot;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt;width&lt;/span&gt;&lt;/em&gt; height=&lt;em&gt;&lt;span style=&quot;font-family:&amp;quot;Courier New&amp;quot;&quot;&gt;height&lt;/span&gt;&lt;/em&gt;&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/applet&amp;gt;&lt;/pre&gt;&lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h1&gt;Creating a JAR File&lt;/h1&gt;

&lt;p&gt;The basic format of the command for creating a JAR file is: &lt;/p&gt;

&lt;pre&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:12.0pt;
mso-bidi-font-size:10.0pt&quot;&gt;jar cf &lt;i&gt;jar-file input-file(s)(space sepatated)&lt;/i&gt;&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;

&lt;p&gt;The options and arguments used in this command are: &lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;b style=&quot;mso-bidi-font-weight:
     normal&quot;&gt;&lt;span style=&quot;font-size:15.0pt;mso-bidi-font-size:10.0pt&quot;&gt;c&lt;/span&gt;&lt;/b&gt;&lt;/tt&gt;
     option indicates that you want to &lt;em&gt;create&lt;/em&gt; a JAR file. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;b style=&quot;mso-bidi-font-weight:
     normal&quot;&gt;&lt;span style=&quot;font-size:15.0pt;mso-bidi-font-size:10.0pt&quot;&gt;f&lt;/span&gt;&lt;/b&gt;&lt;/tt&gt;
     option indicates that you want the output to go to a &lt;em&gt;file&lt;/em&gt; rather
     than to stdout. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list .5in&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:
     10.0pt&quot;&gt;jar-file&lt;/span&gt;&lt;/tt&gt; is the name that you want the resulting JAR
     file to have. You can use any filename for a JAR file. By convention, JAR
     filenames are given a &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;.jar&lt;/span&gt;&lt;/tt&gt;
     extension, though this is not required. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l3 level1 lfo2;tab-stops:list .5in&quot;&gt;&lt;span style=&quot;mso-ignore:
     vglayout;position:absolute;z-index:2;left:0px;margin-left:-38px;
     margin-top:9px;width:52px;height:29px&quot;&gt;&lt;img src=&quot;file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image002.gif&quot; height=&quot;29&quot; width=&quot;52&quot;&gt;&lt;/span&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:
     10.0pt&quot;&gt;input-file(s)&lt;/span&gt;&lt;/tt&gt; argument is a space-separated list of
     one or more files that you want to include in your JAR file. The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;input-file(s)&lt;/span&gt;&lt;/tt&gt; argument can contain
     the wildcard &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;*&lt;/span&gt;&lt;/tt&gt; symbol. If
     any of the &quot;input-files&quot; are directories, the contents of those
     directories are added to the JAR archive recursively. &lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;c&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;f&lt;/span&gt;&lt;/tt&gt; options can appear in either order, but
there must not be any space between them. &lt;/p&gt;

&lt;p&gt;This command will generate a compressed JAR file and place it in the current
directory. The command will also generate &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;a
default manifest&lt;/b&gt; file for the JAR archive. &lt;/p&gt;

&lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&amp;nbsp;The metadata in the JAR file,
such as the entry names, comments, and contents of the manifest, must be
encoded in UTF8. (UTF-8 stands for Unicode Transformation Format-8. ... UTF-8
encodes each Unicode character as a variable number of 1 to 4 octets)&lt;/p&gt;

&lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;

&lt;/div&gt;

&lt;p&gt;You can add any of these additional options to the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;cf&lt;/span&gt;&lt;/tt&gt; options of the basic command: &lt;/p&gt;

&lt;table class=&quot;MsoNormalTable&quot; style=&quot;mso-cellspacing:1.5pt;
 mso-padding-alt:2.25pt 2.25pt 2.25pt 2.25pt&quot; border=&quot;1&quot; cellpadding=&quot;0&quot;&gt;
 &lt;tbody&gt;&lt;tr style=&quot;mso-yfti-irow:0;mso-yfti-firstrow:yes&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;strong&gt;jar command
  options &lt;/strong&gt;&lt;/p&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;b&gt;Option&lt;/b&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;b&gt;Description&lt;/b&gt;&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:1&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;v&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p&gt;Produces &lt;em&gt;verbose&lt;/em&gt; output on stdout while the JAR
  file is being built. The verbose output tells you the name of each file as
  it's added to the JAR file.&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:2&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;0&lt;/span&gt;&lt;/tt&gt; (zero)&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p&gt;Indicates that you don't want the JAR file to be
  compressed.&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:3&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;M&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p&gt;Indicates that the default manifest file should not be
  produced.&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:4&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;m&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p&gt;Used to include manifest information from an existing
  manifest file. The format for using this option is: &lt;/p&gt;
  &lt;pre&gt;jar cmf existing-manifest jar-file input-file(s)&lt;/pre&gt;
  &lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;
  &lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;
  &lt;/div&gt;
  &lt;p&gt;&lt;strong&gt;Warning:&lt;/strong&gt;&amp;nbsp;The manifest must end with
  a new line or carriage return. The last line will not be parsed properly if
  it does not end with a new line or carriage return. &lt;/p&gt;
  &lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;
  &lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;
  &lt;/div&gt;
  
  &lt;/td&gt;
 &lt;/tr&gt;
 &lt;tr style=&quot;mso-yfti-irow:5;mso-yfti-lastrow:yes&quot;&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt;&lt;/p&gt;
  &lt;/td&gt;
  &lt;td style=&quot;padding:2.25pt 2.25pt 2.25pt 2.25pt&quot;&gt;
  &lt;p&gt;To change directories during execution of the command. See
  below for an example.&lt;/p&gt;
  &lt;/td&gt;
 &lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;

&lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt;&amp;nbsp; When you create a JAR file, the
time of creation is stored in the JAR file. Therefore, even if the contents of
the JAR file do not change, when you create a JAR file multiple times, the
resulting files are not exactly identical. You should be aware of this when you
are using JAR files in a build environment. It is recommended that you use
versioning information in the manifest file, rather than creation time, to control
versions of a JAR file... &lt;/p&gt;

&lt;div style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;

&lt;hr align=&quot;center&quot; size=&quot;2&quot; width=&quot;100%&quot;&gt;

&lt;/div&gt;

&lt;h2&gt;&lt;a name=&quot;example&quot;&gt;An Example&lt;/a&gt;&lt;/h2&gt;

&lt;p&gt;&lt;span style=&quot;mso-bookmark:example&quot;&gt;Let us look at an example. A simple &lt;/span&gt;&lt;span style=&quot;mso-bookmark:example&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe&lt;/span&gt;&lt;/tt&gt;
applet. You can see the source code of this Applet at &lt;/span&gt;TicTacToe.java.
This demo contains a bytecode class file, audio files, and images having this
structure: &lt;/p&gt;

&lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;img src=&quot;file:///C:/DOCUME%7E1/ADMINI%7E1/LOCALS%7E1/Temp/msohtml1/01/clip_image003.gif&quot; alt=&quot;TicTacToe folder Hierarchy&quot; align=&quot;BOTTOM&quot; height=&quot;121&quot; width=&quot;338&quot;&gt;&lt;/p&gt;

&lt;p style=&quot;text-align:center&quot; align=&quot;center&quot;&gt;&lt;strong&gt;TicTacToe
folder Hierarchy&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;audio&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; subdirectories contain sound files
and GIF images used by the applet. &lt;/p&gt;

&lt;p&gt;You can obtain all these files from &lt;i&gt;jar/examples&lt;/i&gt; directory when you
download the entire Tutorial online. To package this demo into a single JAR
file named &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt;, you
would run this command from inside the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe&lt;/span&gt;&lt;/tt&gt;
directory: &lt;/p&gt;

&lt;pre&gt;jar cvf TicTacToe.jar TicTacToe.class audio images&lt;/pre&gt;

&lt;p&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;audio&lt;/span&gt;&lt;/tt&gt; and
&lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; arguments represent
directories, so the Jar tool will recursively place them and their contents in
the JAR file. The generated JAR file &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt;
will be placed in the current directory. Because the command used the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;v&lt;/span&gt;&lt;/tt&gt; option for verbose output, you would see
something similar to this output when you run the command: &lt;/p&gt;

&lt;pre&gt;adding: TicTacToe.class (in=3825) (out=2222) (deflated 41%)&lt;/pre&gt;&lt;pre&gt;adding: audio/ (in=0) (out=0) (stored 0%)&lt;/pre&gt;&lt;pre&gt;adding: audio/beep.au (in=4032) (out=3572) (deflated 11%)&lt;/pre&gt;&lt;pre&gt;adding: audio/ding.au (in=2566) (out=2055) (deflated 19%)&lt;/pre&gt;&lt;pre&gt;adding: audio/return.au (in=6558) (out=4401) (deflated 32%)&lt;/pre&gt;&lt;pre&gt;adding: audio/yahoo1.au (in=7834) (out=6985) (deflated 10%)&lt;/pre&gt;&lt;pre&gt;adding: audio/yahoo2.au (in=7463) (out=4607) (deflated 38%)&lt;/pre&gt;&lt;pre&gt;adding: images/ (in=0) (out=0) (stored 0%)&lt;/pre&gt;&lt;pre&gt;adding: images/cross.gif (in=157) (out=160) (deflated -1%)&lt;/pre&gt;&lt;pre&gt;adding: images/not.gif (in=158) (out=161) (deflated -1%)&lt;/pre&gt;

&lt;p&gt;You can see from this output that the JAR file &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt; is compressed. The Jar tool compresses files
by default. You can turn off the compression feature by using the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;0&lt;/span&gt;&lt;/tt&gt; (zero) option, so that the command would
look like: &lt;/p&gt;

&lt;pre&gt;jar &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:16.0pt&quot;&gt;cvf0&lt;/span&gt;&lt;/b&gt; TicTacToe.jar TicTacToe.class audio images&lt;/pre&gt;

&lt;p&gt;You might want to avoid compression, for example, to increase the speed with
which a JAR file could be loaded by a browser. Uncompressed JAR files can
generally be loaded more quickly than compressed files because the need to
decompress the files during loading is eliminated. However, there is a tradeoff
in that download time over a network may be longer for larger, uncompressed
files. &lt;/p&gt;

&lt;p&gt;The Jar tool will accept arguments that use the wildcard &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;*&lt;/span&gt;&lt;/tt&gt; symbol. As long as there weren't any
unwanted files in the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe&lt;/span&gt;&lt;/tt&gt;
directory, you could have used this alternative command to construct the JAR
file: &lt;/p&gt;

&lt;pre&gt;jar cvf TicTacToe.jar *&lt;/pre&gt;

&lt;p&gt;Though the verbose output doesn't indicate it, the Jar tool automatically
adds a manifest file to the JAR archive with path name &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;META-INF/MANIFEST.MF&lt;/span&gt;&lt;/tt&gt;. See the Working with
Manifest Files: The Basics section for information about manifest files. &lt;/p&gt;

&lt;p&gt;In the above example, the files in the archive retained their relative path
names and directory structure. The Jar tool provides the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt; option that you can use to create a JAR
file in which the relative paths of the archived files are not preserved. It's
modeled after TAR's &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt; option. &lt;/p&gt;

&lt;p&gt;As an example, suppose you wanted to put audio files and gif images used by
the TicTacToe demo into a JAR file, and that you wanted all the files to be on
the top level, with no directory hierarchy. You could accomplish that by
issuing this command from the parent directory of the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; and &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;audio&lt;/span&gt;&lt;/tt&gt; directories: &lt;/p&gt;

&lt;pre&gt;jar cf ImageAudio.jar -C images . -C audio .&lt;/pre&gt;

&lt;p&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&amp;nbsp;images&lt;/span&gt;&lt;/tt&gt;
part of this command directs the Jar tool to go to the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; directory, and the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;.&lt;/span&gt;&lt;/tt&gt; following &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;-C&amp;nbsp;images&lt;/span&gt;&lt;/tt&gt; directs the Jar tool to archive all the
contents of that directory. The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&amp;nbsp;audio&amp;nbsp;.&lt;/span&gt;&lt;/tt&gt;
part of the command then does the same with the &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;audio&lt;/span&gt;&lt;/tt&gt; directory. The resulting JAR file would have this
table of contents: &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;&lt;pre&gt;cross.gif&lt;/pre&gt;&lt;pre&gt;not.gif&lt;/pre&gt;&lt;pre&gt;beep.au&lt;/pre&gt;&lt;pre&gt;ding.au&lt;/pre&gt;&lt;pre&gt;return.au&lt;/pre&gt;&lt;pre&gt;yahoo1.au&lt;/pre&gt;&lt;pre&gt;yahoo2.au&lt;/pre&gt;

&lt;p&gt;By contrast, suppose that you used a command that did not
employ the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt; option: &lt;/p&gt;

&lt;pre&gt;jar cf ImageAudio.jar images audio&lt;/pre&gt;

&lt;p&gt;The resulting JAR file would have this table of contents: &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;&lt;pre&gt;images/cross.gif&lt;/pre&gt;&lt;pre&gt;images/not.gif&lt;/pre&gt;&lt;pre&gt;audio/beep.au&lt;/pre&gt;&lt;pre&gt;audio/ding.au&lt;/pre&gt;&lt;pre&gt;audio/return.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo1.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo2.au&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;

&lt;h1&gt;Default Manifest&lt;/h1&gt;

&lt;p&gt;When you create a JAR file, it automatically receives a
default manifest file. There can be only one manifest file in an archive, and
it always has the pathname &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;

&lt;p&gt;When you create a JAR file, the default manifest file simply contains the
following: &lt;/p&gt;

&lt;pre&gt;Manifest-Version: 1.0&lt;/pre&gt;&lt;pre&gt;Created-By: 1.6.0 (Sun Microsystems Inc.)&lt;/pre&gt;

&lt;p&gt;These lines show that a manifest's entries take the form of &quot;header: value&quot;
pairs. The name of a header is separated from its value by a colon. The default
manifest conforms to version 1.0 of the manifest specification and was created
by the 1.6.0 version of the JDK. &lt;/p&gt;

&lt;p&gt;The manifest can also contain information about the other files that are
packaged in the archive. Exactly what file information should be recorded in
the manifest depends on how you intend to use the JAR file. The default
manifest makes no assumptions about what information it should record about
other files. &lt;/p&gt;

&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;

&lt;h1&gt;Extracting the Contents of a JAR File&lt;/h1&gt;

&lt;p&gt;The basic command to use for extracting the contents of a
JAR file is: &lt;/p&gt;

&lt;pre&gt;jar xf &lt;i&gt;jar-file [archived-file(s)]&lt;/i&gt;&lt;/pre&gt;

&lt;p&gt;Let's look at the options and arguments in this command: &lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo3;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;x&lt;/span&gt;&lt;/tt&gt; option indicates that you want to &lt;em&gt;extract&lt;/em&gt;
     files from the JAR archive. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo3;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;f&lt;/span&gt;&lt;/tt&gt; options indicates that the JAR &lt;em&gt;file&lt;/em&gt;
     from which files are to be extracted is specified on the command line,
     rather than through stdin. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo3;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;jar-file&lt;/span&gt;&lt;/tt&gt; argument is the filename (or
     path and filename) of the JAR file from which to extract files. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l4 level1 lfo3;tab-stops:list .5in&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:
     10.0pt&quot;&gt;archived-file(s)&lt;/span&gt;&lt;/tt&gt; is an optional argument consisting of
     a space-separated list of the files to be extracted from the archive. If
     this argument is not present, the Jar tool will extract all the files in
     the archive. &lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;As usual, the order in which the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;x&lt;/span&gt;&lt;/tt&gt;
and &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;f&lt;/span&gt;&lt;/tt&gt; options appear in the
command doesn't matter, but there must not be a space between them. &lt;/p&gt;

&lt;p&gt;When extracting files, the Jar tool makes copies of the desired files and
writes them to the current directory, reproducing the directory structure that
the files have in the archive. The original JAR file remains unchanged. &lt;/p&gt;

&lt;p&gt;&amp;nbsp;&lt;/p&gt;

&lt;h2&gt;An Example&lt;/h2&gt;

&lt;p&gt;Let's extract some files from the TicTacToe JAR file we've
been using in previous sections. Recall that the contents of &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt; are: &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;&lt;pre&gt;TicTacToe.class&lt;/pre&gt;&lt;pre&gt;audio/&lt;/pre&gt;&lt;pre&gt;audio/beep.au&lt;/pre&gt;&lt;pre&gt;audio/ding.au&lt;/pre&gt;&lt;pre&gt;audio/return.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo1.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo2.au&lt;/pre&gt;&lt;pre&gt;images/&lt;/pre&gt;&lt;pre&gt;images/cross.gif&lt;/pre&gt;&lt;pre&gt;images/not.gif&lt;/pre&gt;

&lt;p&gt;Suppose you want to extract the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe&lt;/span&gt;&lt;/tt&gt;
class file and the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;cross.gif&lt;/span&gt;&lt;/tt&gt;
image file. To do so, you can use this command: &lt;/p&gt;

&lt;pre&gt;jar xf TicTacToe.jar TicTacToe.class images/cross.gif&lt;/pre&gt;&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;

&lt;h1&gt;Updating a JAR File&lt;/h1&gt;

&lt;p&gt;The Jar tool provides a &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;u&lt;/span&gt;&lt;/tt&gt;
option which you can use to update the contents of an existing JAR file by
modifying its manifest or by adding files. &lt;/p&gt;

&lt;p&gt;The basic command for adding files has this format: &lt;/p&gt;

&lt;pre&gt;jar uf &lt;i&gt;jar-file input-file(s)&lt;/i&gt;&lt;/pre&gt;

&lt;p&gt;In this command: &lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo4;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;u&lt;/span&gt;&lt;/tt&gt; option indicates that you want to &lt;em&gt;update&lt;/em&gt;
     an existing JAR file. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo4;tab-stops:list .5in&quot;&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;f&lt;/span&gt;&lt;/tt&gt; option indicates that the JAR file
     to update is specified on the command line. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo4;tab-stops:list .5in&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:
     10.0pt&quot;&gt;jar-file&lt;/span&gt;&lt;/tt&gt; is the existing JAR file that's to be
     updated. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l1 level1 lfo4;tab-stops:list .5in&quot;&gt;&lt;tt&gt;&lt;span style=&quot;font-size:
     10.0pt&quot;&gt;input-file(s)&lt;/span&gt;&lt;/tt&gt; is a space-deliminated list of one or
     more files that you want to add to the Jar file. &lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Any files already in the archive having the same pathname as a file being
added will be overwritten. &lt;/p&gt;

&lt;p&gt;When creating a new JAR file, you can optionally use the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt; option to indicate a change of
directory. &lt;/p&gt;

&lt;h2&gt;Examples&lt;/h2&gt;

&lt;p&gt;Recall that &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt;
has these contents: &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;&lt;pre&gt;TicTacToe.class&lt;/pre&gt;&lt;pre&gt;audio/&lt;/pre&gt;&lt;pre&gt;audio/beep.au&lt;/pre&gt;&lt;pre&gt;audio/ding.au&lt;/pre&gt;&lt;pre&gt;audio/return.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo1.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo2.au&lt;/pre&gt;&lt;pre&gt;images/&lt;/pre&gt;&lt;pre&gt;images/cross.gif&lt;/pre&gt;&lt;pre&gt;images/not.gif&lt;/pre&gt;

&lt;p&gt;Suppose that you want to add the file &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images/new.gif&lt;/span&gt;&lt;/tt&gt;
to the JAR file. You could accomplish that by issuing this command from the
parent directory of the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt;
directory: &lt;/p&gt;

&lt;pre&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:14.0pt;
mso-bidi-font-size:10.0pt&quot;&gt;jar uf TicTacToe.jar images/new.gif&lt;/span&gt;&lt;/b&gt;&lt;/pre&gt;

&lt;p&gt;The revised JAR file would have this table of contents: &lt;/p&gt;

&lt;pre&gt;META-INF/MANIFEST.MF&lt;/pre&gt;&lt;pre&gt;TicTacToe.class&lt;/pre&gt;&lt;pre&gt;audio/&lt;/pre&gt;&lt;pre&gt;audio/beep.au&lt;/pre&gt;&lt;pre&gt;audio/ding.au&lt;/pre&gt;&lt;pre&gt;audio/return.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo1.au&lt;/pre&gt;&lt;pre&gt;audio/yahoo2.au&lt;/pre&gt;&lt;pre&gt;images/&lt;/pre&gt;&lt;pre&gt;images/cross.gif&lt;/pre&gt;&lt;pre&gt;images/not.gif&lt;/pre&gt;&lt;pre&gt;images/new.gif&lt;/pre&gt;

&lt;p&gt;You can use the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-C&lt;/span&gt;&lt;/tt&gt; option to
&quot;change directories&quot; during execution of the command. For example: &lt;/p&gt;

&lt;pre&gt;jar uf TicTacToe.jar -C images new.gif&lt;/pre&gt;

&lt;p&gt;This command would change to the &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; directory before adding &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;new.gif&lt;/span&gt;&lt;/tt&gt; to the JAR file. The &lt;tt&gt;&lt;span style=&quot;font-size:
10.0pt&quot;&gt;images&lt;/span&gt;&lt;/tt&gt; directory would not be included in the pathname of &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;new.gif&lt;/span&gt;&lt;/tt&gt; when it's added to the archive,
resulting in a table of contents that looks like this: &lt;/p&gt;

&lt;h1&gt;Running JAR-Packaged Software&lt;/h1&gt;

&lt;p&gt;Now that you've learned how to create JAR files, how do you
actually run the code that you've packaged? Consider these three scenarios: &lt;/p&gt;

&lt;ul type=&quot;disc&quot;&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l0 level1 lfo5;tab-stops:list .5in&quot;&gt;Your JAR file contains an
     applet that is to be run inside a browser. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l0 level1 lfo5;tab-stops:list .5in&quot;&gt;Your JAR file contains an
     application that is to be invoked from the command line. &lt;/li&gt;&lt;li style=&quot;mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;
     mso-list:l0 level1 lfo5;tab-stops:list .5in&quot;&gt;Your JAR file contains code
     that you want to use as an extension. &lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;This section will cover the first two situations. A separate trail in the
tutorial on the extension mechanism covers the use of JAR files as extensions. &lt;/p&gt;

&lt;h2&gt;Applets Packaged in JAR Files&lt;/h2&gt;

&lt;p&gt;To invoke any applet from an HTML file for running inside a
browser, you need to use the APPLET tag. For more information, see the &lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;i style=&quot;mso-bidi-font-style:normal&quot;&gt;&lt;span style=&quot;font-size:14.0pt;mso-bidi-font-size:12.0pt&quot;&gt;Java Applets&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;span style=&quot;font-size:14.0pt;mso-bidi-font-size:12.0pt&quot;&gt; &lt;/span&gt;lesson. If the
applet is bundled as a JAR file, the only thing you need to do differently is
to use the &lt;em&gt;&lt;b style=&quot;mso-bidi-font-weight:normal&quot;&gt;&lt;span style=&quot;font-size:
14.0pt;mso-bidi-font-size:12.0pt&quot;&gt;ARCHIVE&lt;/span&gt;&lt;/b&gt;&lt;/em&gt; parameter to specify
the relative path to the JAR file. &lt;/p&gt;

&lt;p&gt;As an example, let's use (again!) the TicTacToe demo applet that ships with
the Java™ Development Kit. The APPLET tag in the HTML file that calls the demo
looks like this: &lt;/p&gt;

&lt;pre&gt;&amp;lt;applet code=TicTacToe.class &lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;width=120 height=120&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/applet&amp;gt;&lt;/pre&gt;

&lt;p&gt;If the TicTacToe demo were packaged in a JAR file named &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.jar&lt;/span&gt;&lt;/tt&gt;, you could modify the APPLET
tag with the simple addition of an ARCHIVE parameter: &lt;/p&gt;

&lt;pre&gt;&amp;lt;applet code=TicTacToe.class &lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;archive=&quot;TicTacToe.jar&quot;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;width=120 height=120&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/applet&amp;gt;&lt;/pre&gt;

&lt;p&gt;The ARCHIVE parameter specifies the relative path to the JAR
file that contains &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;TicTacToe.class&lt;/span&gt;&lt;/tt&gt;.
This example assumes that the JAR file and the HTML file are in the same
directory. If they're not, you would need to include the JAR file's relative
path in the ARCHIVE parameter's value. For example, if the JAR file was one directory
below the HTML file in a directory called &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;applets&lt;/span&gt;&lt;/tt&gt;,
the APPLET tag would look like this: &lt;/p&gt;

&lt;pre&gt;&amp;lt;applet code=TicTacToe.class &lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;archive=&quot;applets/TicTacToe.jar&quot;&lt;/pre&gt;&lt;pre&gt;&lt;span style=&quot;mso-spacerun:yes&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;width=120 height=120&amp;gt;&lt;/pre&gt;&lt;pre&gt;&amp;lt;/applet&amp;gt;&lt;/pre&gt;

&lt;h2&gt;&lt;a name=&quot;1.2&quot;&gt;&lt;/a&gt;JAR Files as Applications&lt;/h2&gt;

&lt;p&gt;You can run JAR-packaged applications with the Java
interpreter. The basic command is: &lt;/p&gt;

&lt;pre&gt;java -jar &lt;i&gt;jar-file&lt;/i&gt;&lt;/pre&gt;

&lt;p&gt;The &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;-jar&lt;/span&gt;&lt;/tt&gt; flag
tells the interpreter that the application is packaged in the JAR file format.
You can only specify one JAR file, which must contain all the
application-specific code. &lt;/p&gt;

&lt;p&gt;Before you execute this command make sure the runtime environment has an
information of which class within the JAR file is the application's entry
point. &lt;/p&gt;

&lt;p&gt;To indicate which class is the application's entry point, you must add a &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;Main-Class&lt;/span&gt;&lt;/tt&gt; header to the JAR file's
manifest. The header takes the form: &lt;/p&gt;

&lt;pre&gt;Main-Class: &lt;i&gt;classname&lt;/i&gt;&lt;/pre&gt;

&lt;p&gt;The header's value, &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;classname&lt;/span&gt;&lt;/tt&gt;,
is the name of the class that's the application's entry point. &lt;/p&gt;

&lt;p&gt;When the &lt;tt&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;Main-Class&lt;/span&gt;&lt;/tt&gt; is set in
the manifest file, you can run the application from the command line: &lt;/p&gt;

&lt;pre&gt;java -jar app.jar&lt;/pre&gt;

&lt;p&gt;To run the application from jar file that is in other directory, we need to
specify the path of that directory as below: &lt;code&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;java
-jar path/app.jar&lt;/span&gt;&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;where &lt;code&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;path&lt;/span&gt;&lt;/code&gt; is the
directory path at which this &lt;code&gt;&lt;span style=&quot;font-size:10.0pt&quot;&gt;app.jar&lt;/span&gt;&lt;/code&gt;
resides. &lt;/p&gt;

&lt;pre&gt;&amp;nbsp;&lt;/pre&gt;</description>
            <pubDate>Thu, 07 Jul 2011 08:14:34 +0100</pubDate>
        </item>
    </channel>
</rss>
