Mysql: Grant

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 16

First, use the mysql program to connect to the server as the MySQL root user:

shell> mysql --user=root mysql

If you have assigned a password to the root account, you will also need to supply a
--password or -p option, both for this mysql command and for those later in this section.

After connecting to the server as root, you can add new accounts. The following statements
use GRANT to set up four new accounts:

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';


mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> WITH GRANT OPTION;
mysql> CREATE USER 'admin'@'localhost';
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> CREATE USER 'dummy'@'localhost';

The accounts created by these statements have the following properties:

 Two of the accounts have a user name of monty and a password of some_pass. Both
accounts are superuser accounts with full privileges to do anything. The
'monty'@'localhost' account can be used only when connecting from the local
host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be
used to connect from any host.

It is necessary to have both accounts for monty to be able to connect from anywhere
as monty. Without the localhost account, the anonymous-user account for
localhost that is created by mysql_install_db would take precedence when monty
connects from the local host. As a result, monty would be treated as an anonymous
user. The reason for this is that the anonymous-user account has a more specific Host
column value than the 'monty'@'%' account and thus comes earlier in the user table
sort order. (user table sorting is discussed in Section 5.4.4, “Access Control, Stage 1:
Connection Verification”.)

 The 'admin'@'localhost' account has no password. This account can be used only
by admin to connect from the local host. It is granted the RELOAD and PROCESS
administrative privileges. These privileges enable the admin user to execute the
mysqladmin reload, mysqladmin refresh, and mysqladmin flush-xxx commands,
as well as mysqladmin processlist . No privileges are granted for accessing any
databases. You could add such privileges later by issuing other GRANT statements.
 The 'dummy'@'localhost' account has no password. This account can be used only
to connect from the local host. No privileges are granted. It is assumed that you will
grant specific privileges to the account later.

The statements that create accounts with no password will fail if the NO_AUTO_CREATE_USER
SQL mode is enabled. To deal with this, use an IDENTIFIED BY clause that specifies a
nonempty password.
To check the privileges for an account, use SHOW GRANTS:

mysql> SHOW GRANTS FOR 'admin'@'localhost';


+-----------------------------------------------------+
| Grants for admin@localhost |
+-----------------------------------------------------+
| GRANT RELOAD, PROCESS ON *.* TO 'admin'@'localhost' |
+-----------------------------------------------------+

JAR Files
This topic describes how JAR files are used in the JavaHelp system.

o Using JAR files


o The jar command
o Creating JAR files
o Listing JAR files
o Extracting files from JAR files
o The JAR protocol

Using JAR Files

After you create your help information, you will usually encapsulate it into a single
file and compress it for delivery to your users. The JavaHelp system uses the JAR
(Java ARchive) format for encapsulation and compression. The JAR file format is
based on the popular ZIP file format. The JavaHelp system automatically extracts
information from the JAR file when it is required.

Until support is available from GUI-base help authoring tools, the jar command
(located in the J2SE

bin folder) must be used from a command-line prompt to create, read, and extract data
from JAR files.

Sample Help Hierarchy

The following sections refer to this sample help hierarchy:


The jar Command

The jar command syntax is:

jar [ctxvfm] [jar-file] [manifest-file] files ...


Option flags are:
c create new archive
t list table of contents for archive
x extract named (or all) files from archive
v generate verbose output on standard error
f specify JAR file name
m include manifest information from specified
manifest file
For more detailed information about the jar command or format, please refer to
http://java.sun.com/beans/jar.html.

The jar command is located in the bin directory of the J2SE.

Creating JAR Files

To create a JAR file from your help files, make the top level help folder the current
folder. The jar command descends recursively through the different directories and
copies all of the files to the JAR file.

Use the following steps to create a JAR file named my_help.jar from the hierarchy
example above:

1. C:\> cd ...\help (where "..." is the path above the \help folder)
2. C:...\help> jar -cvf my_help.jar *
The jar -cvf command copies all the files in the \help folder and in all folders
hierarchically beneath it into a JAR file named my_help.jar. As the command
creates the JAR file, it reports its progress with output like the following:
adding: my_helpset.hs (in=5757) (out=2216) (deflated 61%)
This indicates that the file my_helpset.hs was added to the JAR file and compressed
61% (from 5272 bytes to 2150 bytes).

When you create a JAR file, the jar command automatically creates a manifest file
for you. The manifest file consists of a list of files present within the archive itself.

Listing JAR Files

Use the t option to list the files included in a JAR file:

C:\> jar -tvf my_help.jar


5272 Fri Apr 03 14:48:04 PST 1998 META-INF/MANIFEST.MF
5757 Fri Apr 03 12:21:04 PST 1998 my_helpset.hs
1345 Wed Feb 18 14:40:16 PST 1998 my_map.jhm
1478 Wed Feb 18 14:40:16 PST 1998 my_toc.xml
4678 Thu Mar 12 07:28:54 PST 1998 my_index.xml
2345 Thu Mar 12 07:28:32 PST 1998 JavaHelpSearch/DOCS
3456 Thu Mar 19 11:26:56 PST 1998 JavaHelpSearch/DOCS.TAB
1457 Fri Mar 13 13:30:06 PST 1998 JavaHelpSearch/OFFSETS
1465 Thu Mar 19 11:26:56 PST 1998 JavaHelpSearch/POSITIONS
1234 Thu Mar 19 11:26:56 PST 1998 JavaHelpSearch/SCHEMA
3214 Thu Mar 19 11:26:56 PST 1998 JavaHelpSearch/TMAP
3113 Thu Mar 12 07:28:36 PST 1998
topics/topic1/subtopicA/topic.html
230 Thu Mar 19 11:26:56 PST 1998
topics/topic1/subtopicB/topic.html
1661 Wed Feb 18 14:40:46 PST 1998
topics/topic2/subtopicA/topic.html
3181 Wed Feb 18 14:40:46 PST 1998
topics/topic2/subtopicB/topic.html
1667 Thu Mar 19 11:26:56 PST 1998
topics/topic3/subtopicA/topic.html
9072 Thu Mar 12 07:28:36 PST 1998
topics/topic3/subtopicB/topic.html
3673 Thu Mar 19 11:26:56 PST 1998
topics/topic3/subtopicC/topic.html
551 Fri Mar 13 13:30:12 PST 1998
topics/topic3/subtopicD/topic.html

Extracting Files from JAR Files

Use the x option to extract files from the JAR file:

C:\> jar -xvf my_help.jar


extracted: META-INF/MANIFEST.MF
extracted: my_helpset.hs
extracted: my_map.jhm
extracted: my_toc.xml
extracted: my_index.xml
extracted: JavaHelpSearch/DOCS
extracted: JavaHelpSearch/DOCS.TAB
extracted: JavaHelpSearch/OFFSETS
extracted: JavaHelpSearch/POSITIONS
extracted: JavaHelpSearch/SCHEMA
extracted: JavaHelpSearch/TMAP
extracted: topics/topic1/subtopicA/topic.html
extracted: topics/topic1/subtopicB/topic.html
extracted: topics/topic2/subtopicA/topic.html
extracted: topics/topic2/subtopicB/topic.html
extracted: topics/topic3/subtopicA/topic.html
extracted: topics/topic3/subtopicB/topic.html
extracted: topics/topic3/subtopicC/topic.html
extracted: topics/topic3/subtopicD/topic.html

Note that it is not necessary to extract files from the JAR file to use them with the
JavaHelp system. The JavaHelp system reads files directly from the JAR file as they
are required.

The JAR: Protocol

The Java 2 SDK implements a protocol for referring explicitly to files within JAR
TM

files. The syntax of the jar: protocol is:

jar:<url>!/{entry}
The jar: protocol can be used to refer to entries within JAR files, the entire JAR file,
or a directory as base URLs (JAR directory).

Examples:

An entry within a JAR file:

jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class

A JAR file:

jar:file://www.foo.com/bar/baz.jar!/

A JAR directory:

jar:file://www.foo.com/bar/baz.jar!/COM/foo/

  "!/" is called the separator.

Index File
The index file describes to the index navigator the content and layout of the index.
The format of the index file is based on the World Wide Web Consortium Extended
Markup Language (XML). The following is a very small example of an index file:

<?xml version='1.0' encoding='ISO-8859-1' ?>

<!DOCTYPE index

PUBLIC

"-//Sun Microsystems Inc.//DTD

JavaHelp Index Version 2.0//EN"

"http://java.sun.com/products/javahelp/index_2_0.dtd">

<index version="2.0">

<indexitem text=".prof extension (profile data)"

target="prof.profile" />

<indexitem text="accelerators (keyboard), see 'keyboard commands'" />

<indexitem text="adding existing portfolio" target="proj.import" />

<indexitem text="adding existing project">

<indexitem text="naming project" target="proj.importdirectory" />

<indexitem text="naming storage directory"

target="proj.importdirectory" />

<indexitem text="procedures for" target="proj.importproject2" />

</indexitem>

<indexitem text="analyzing program performance, see 'profiler'" />

<indexitem text="Java Applets">


<indexitem text="overview" target="applet_over"
presentationtype="javax.help.SecondaryWindow

presentationname="mainsw">
<indexitem text="editing in content page"
target="applet_editing">

<indexitem text="inserting in content page"

target="applet_insert">
</indexitem>

</index>

The Index Tags

The following table describes the index tags:

<index> Defines the index. It can contains <indexitem> tags and the
following optional attributes.

Language for the index. Use the standard


xml:lang="lang" locale-country-variant format.

Some examples:

xml:lang="de"

xml:lang="en"

xml:lang="en-US"
version="1.0"|"2.0" Version of JavaHelp software.
.
<indexitem> Defines an index entry. Nesting entry1 within entry2 defines entry2
to be hierarchically contained within entry1. Uses the following
attributes:

Language for the index item. Use the standard


xml:lang="lang" locale-country-variant format.

Some examples:

xml:lang="de"

xml:lang="en"

xml:lang="en-US"
text="string" Specifies the text that displays in the index.
target="string" (optional) Specifies the map ID of the topic
that displays when the entry is chosen by the
user. IDs are defined (associated with a URL)
in the map file. If this attribute is not used, the
index entry does not link to a topic (probably
because it's being used to group sub-entries).
mergetype="class" (optional) The path to a valid merge class for
the view. The default merge type for an index
is javax.help.AppendMerge.

The merge classes are:

javax.help.UniteAppendMerge

javax.help.SortMerge

javax.help.AppendMerge

javax.help.NoMerge

For more information, see Merging Helpsets.


expand="true|false" (optional) Specifies whether to expand the
index item and its subitems when the index
initially opens. The default setting is "none",
a setting that expands only the top level items.
presentationtype (optional) Specifies the type of window in
which the topic will be displayed (defined in
the <presentation> section of the .hs file). For
more information, see the presentation feature
in Helpset File.
presentationname (optional) Specifies the name of the window
in which the topic will be displayed.

jar-The Java Archive Tool


Combines multiple files into a single JAR archive file.

 Synopsis
 Description
 Options
 Command Line Argument Files
 Examples
 See Also

SYNOPSIS
Create jar file
jar c[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar c[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar c[v0M] [-C dir] inputfiles [-Joption]
jar c[v0]m manifest [-C dir] inputfiles [-Joption]
Update jar file
jar u[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar u[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar u[v0M] [-C dir] inputfiles [-Joption]
jar u[v0]m manifest [-C dir] inputfiles [-Joption]
Extract jar file
jar x[v]f jarfile [inputfiles] [-Joption]
jar x[v] [inputfiles] [-Joption]
List table of contents of jar file
jar t[v]f jarfile [inputfiles] [-Joption]
jar t[v] [inputfiles] [-Joption]
Add index to jar file
jar i jarfile [-Joption]

where:

cuxtiv0Mmf
Options that control the jar command.
jarfile
Jar file to be created (c), updated (u), extracted (x), or have its table of
contents viewed (t). The f option and filename jarfile are a pair -- if
either is present, they must both appear. Note that omitting f and
jarfile accepts a "jar file" from standard input (for x and t) or sends the
"jar file" to standard output (for c and u).
inputfiles
Files or directories, separated by spaces, to be combined into jarfile
(for c and u), or to be extracted (for x) or listed (for t) from jarfile. All
directories are processed recursively. The files are compressed unless
option O (zero) is used.
manifest
Pre-existing manifest file whose name: value pairs are to be included
in MANIFEST.MF in the jar file. The m option and filename
manifesfile are a pair -- if either is present, they must both appear. The
letters m and f must appear in the same order that manifest and jarfile
appear.
-C  dir
Temporarily changes directories to dir while processing the following
inputfiles argument. Multiple -C dir inputfiles sets are allowed.
-Joption
Option to be passed into the Java runtime environment. (There must be
no space between -J and option).

DESCRIPTION
The jar tool combines multiple files into a single JAR archive file. jar is a general-purpose
archiving and compression tool, based on ZIP and the ZLIB compression format. However,
jar was designed mainly to facilitate the packaging of java applets or applications into a
single archive. When the components of an applet or application (.class files, images and
sounds) are combined into a single archive, they may be downloaded by a java agent (like a
browser) in a single HTTP transaction, rather than requiring a new connection for each piece.
This dramatically improves download times. jar also compresses files and so further
improves download time. In addition, it allows individual entries in a file to be signed by the
applet author so that their origin can be authenticated. The syntax for the jar tool is almost
identical to the syntax for the tar command. A jar archive can be use as a class path entry,
whether it is compressed or not.

Typical usage to combine files into a jar file is:

% jar cf myFile.jar *.class


In this example, all the class files in the current directory are placed into the file named
"myFile.jar". A manifest file entry named META-INF/MANIFEST.MF is automatically
generated by the jar tool and is always the first entry in the jar file. The manifest file is the
place where any meta-information about the archive is stored as name: value pairs. Refer to
the JAR file specification for details about how meta-information is stored in the manifest
file.

If you have a pre-existing manifest file whose name: value pairs you want the jar tool to
include for the new jar archive, you can specify it using the m option:

% jar cmf myManifestFile myFile.jar *.class


Be sure that any pre-existing manifest file that you use ends with a new line. The last line of a
manifest file will not be parsed if it doesn't end with a new line character. Note that when you
specify "cfm" instead of "cmf" (i.e., you invert the order of the "m" and "f" options), you
need to specify the name of the jar archive first, followed by the name of the manifest file:
% jar cfm myFile.jar myManifestFile *.class
The manifest is in a text format inspired by RFC822 ASCII format, so it is easy to view and
process manifest-file contents.

To extract the files from a jar file, use x, as in:

% jar xf myFile.jar

To extract only certain files from a jar file, supply their filenames:

% jar xf myFile.jar foo bar


Beginning with version 1.3 of the Java 2 SDK, the jar utility supports JarIndex, which
allows application class loaders to load classes more efficiently from jar files. If an
application or applet is bundled into multiple jar files,  only the necessary jar files will be
downloaded and opened to load classes. This performance optimization is enabled by running
jar with the i option. It will generate package location information for the specified main
jar file and all the jar files it depends on, which need to be specified in the Class-Path
attribute of the main jar file's manifest.

% jar i main.jar

In this example, an INDEX.LIST file is inserted into the META-INF directory of main.jar.
The application class loader will use the information stored in this file for efficient class
loading.  Refer to the JarIndex specification for details about how location information is
stored in the index file.

A standard way to copy directories is to first compress files in dir1 to standard out, then
extract from standard in to dir2 (omitting f from both jar commands):

% (cd dir1; jar c .) | (cd dir2; jar x)

Examples of using the jar tool to operate on jar files and jar file manifests are provided below
and in the Jar trail of the Java Tutorial.

OPTIONS
c
Creates a new archive to file named jarfile (if f is specified) or to standard
output (if f and jarfile are omitted). Add to it the files and directories specified
by inputfiles.
u
Updates an existing file jarfile (when f is specified) by adding to it files and
directories specified by inputfiles. For example:
jar uf foo.jar foo.class
would add the file foo.class to the existing jar file foo.jar. The u option
can also update the manifest entry, as given by this example:
jar umf manifest foo.jar
updates the foo.jar manifest with the name: value pairs in manifest.
x
Extracts files and directories from jarfile (if f is specified) or standard input (if
f and jarfile are omitted). If inputfiles is specified, only those specified files
and directories are extracted. Otherwise, all files and directories are extracted.
t
Lists the table of contents from jarfile (if f is specified) or standard input (if f
and jarfile are omitted). If inputfiles is specified, only those specified files and
directories are listed. Otherwise, all files and directories are listed.
i
Generate index information for the specified jarfile and its dependent jar files.
For example:
jar i foo.jar
would generate an INDEX.LIST file in foo.jar which contains location
information for each package in foo.jar and all the jar files specified in the
Class-Path attribute of foo.jar. See the index example.

f
Specifies the file jarfile to be created (c), updated (u), extracted (x), indexed
(i), or viewed (t). The f option and filename jarfile are a pair -- if present,
they must both appear. Omitting f and jarfile accepts a "jar file" from standard
input (for x and t) or sends the "jar file" to standard output (for c and u).
v
Generates verbose output to standard output. Examples shown below.
0
(zero) Store without using ZIP compression.
M
Do not create a manifest file entry (for c and u), or delete a manifest file entry
if one exists (for u).
m
Includes name: value attribute pairs from the specified manifest file manifest
in the file at META-INF/MANIFEST.MF. A name: value pair is added unless one
already exists with the same name, in which case its value is updated.

On the command line, the letters m and f must appear in the same order that
manifest and jarfile appear. Example use:

jar cmf myManifestFile myFile.jar *.class


You can add special-purpose name: value attribute pairs to the manifest that
aren't contained in the default manifest. Examples of such attributes would be
those for vendor information, version information, package sealing, and to
make JAR-bundled applications executable. See the JAR Files trail in the Java
Tutorial and the Notes for Developers page for examples of using the m option.
-C  dir
Temporarily changes directories (cd dir) during execution of the jar
command while processing the following inputfiles argument. Its operation is
intended to be similar to the -C option of the UNIX tar utility. For example:
jar uf foo.jar -C classes bar.class
would change to the classes directory and add the bar.class from that
directory to foo.jar. The following command,
jar uf foo.jar -C classes . -C bin xyz.class
would change to the classes directory and add to foo.jar all files within the
classes directory (without creating a classes directory in the jar file), then
change back to the original directory before changing to the bin directory to
add xyz.class to foo.jar. If classes holds files bar1 and bar2, then here's
what the jar file would contain using jar tf foo.jar:
META-INF/
META-INF/MANIFEST.MF
bar1
bar2
xyz.class
-Joption
Pass option to the Java runtime environment, where option is one of the
options described on the reference page for the java application launcher. For
example, -J-Xmx48M sets the maximum memory to 48 megabytes. It is a
common convention for -J to pass options to the underlying runtime
environment.

COMMAND LINE ARGUMENT FILES


To shorten or simplify the jar command line, you can specify one or more files that
themselves contain arguments to the jar command (except -J options). This enables you to
create jar commands of any length, overcoming command line limits imposed by the
operating system.

An argument file can include options and filenames. The arguments within a file can be
space-separated or newline-separated. Filenames within an argument file are relative to the
current directory, not the location of the argument file. Wildcards (*) that might otherwise be
expanded by the operating system shell are not expanded. Use of the '@' character to
recursively interpret files is not supported. The -J options are not supported because they are
passed to the launcher, which does not support argument files.

When executing jar, pass in the path and name of each argument file with the '@' leading
character. When jar encounters an argument beginning with the character `@', it expands the
contents of that file into the argument list.

For example, you could use a single argument file named "classes.list" to hold the names
of the files:

% find . -name '*.class' -print > classes.list

Then execute the jar command passing in the argfile:

% jar cf my.jar @classes.list


An argument file can be passed in with a path, but any filenames inside the argument file that
have relative paths are relative to the current working directory, not the path passed in. Here's
such an example:
% jar @path1/classes.list

EXAMPLES
To add all the files in a particular directory to an archive (overwriting contents if the archive
already exists). Enumerating verbosely (with the "v" option) will tell you more information
about the files in the archive, such as their size and last modified date.
% ls
1.au Animator.class monkey.jpg
2.au Wave.class spacemusic.au
3.au at_work.gif

% jar cvf bundle.jar *


added manifest
adding: 1.au(in = 2324) (out= 67)(deflated 97%)
adding: 2.au(in = 6970) (out= 90)(deflated 98%)
adding: 3.au(in = 11616) (out= 108)(deflated 99%)
adding: Animator.class(in = 2266) (out= 66)(deflated 97%)
adding: Wave.class(in = 3778) (out= 81)(deflated 97%)
adding: at_work.gif(in = 6621) (out= 89)(deflated 98%)
adding: monkey.jpg(in = 7667) (out= 91)(deflated 98%)
adding: spacemusic.au(in = 3079) (out= 73)(deflated 97%)
If you already have separate subdirectories for images, audio files and classes, you can
combine them into a single jar file:
% ls -F
audio/ classes/ images/

% jar cvf bundle.jar audio classes images


added manifest
adding: audio/(in = 0) (out= 0)(stored 0%)
adding: audio/1.au(in = 2324) (out= 67)(deflated 97%)
adding: audio/2.au(in = 6970) (out= 90)(deflated 98%)
adding: audio/3.au(in = 11616) (out= 108)(deflated 99%)
adding: audio/spacemusic.au(in = 3079) (out= 73)(deflated 97%)
adding: classes/(in = 0) (out= 0)(stored 0%)
adding: classes/Animator.class(in = 2266) (out= 66)(deflated 97%)
adding: classes/Wave.class(in = 3778) (out= 81)(deflated 97%)
adding: images/(in = 0) (out= 0)(stored 0%)
adding: images/monkey.jpg(in = 7667) (out= 91)(deflated 98%)
adding: images/at_work.gif(in = 6621) (out= 89)(deflated 98%)

% ls -F
audio/ bundle.jar classes/ images/
To see the entry names in the jarfile, use the "t" option:
% jar tf bundle.jar
META-INF/
META-INF/MANIFEST.MF
audio/1.au
audio/2.au
audio/3.au
audio/spacemusic.au
classes/Animator.class
classes/Wave.class
images/monkey.jpg
images/at_work.gif

To add an index file to the jar file for speeding up class loading, use the "i" option.

Let's say you split the inter-dependent classes for a stock trade application, into three jar files:
main.jar, buy.jar, and sell.jar. If you specify the Class-path attribute in the main.jar
manifest as:
Class-Path: buy.jar sell.jar
then you can use the i option to speed up your application's class loading time:
% jar i main.jar
An INDEX.LIST file is inserted to the META-INF directory which will enable the
application class loader to download the specified jar files when it is searching for classes or
resources.

Jar File Overview


What is Jar?
Jar stands for Java ARchive. It's a file format based on the popular ZIP file format and is used
for aggregating many files into one. Although Jar can be used as a general archiving tool, the
primary motivation for its development was so that Java applets and their requisite
components (.class files, images and sounds) can be downloaded to a browser in a single
HTTP transaction, rather than opening a new connection for each piece. This greatly
improves the speed with which an applet can be loaded onto a web page and begin
functioning. The Jar format also supports compression, which reduces the size of the file and
improves download time still further. Additionally, individual entries in a Jar file may be
digitally signed by the applet author to authenticate their origin.

Jar is:

 the only archive format that is cross-platform


 the only format that handles audio and image files as well as class files
 backward-compatible with existing applet code
 an open standard, fully extendable, and written in java
 the preferred way to bundle the pieces of a java applet

Jar consists of a zip archive, as defined by PKWARE, containing a manifest file and
potentially signature files, as defined in the Jar File Specification.

The APPLET tag


Changing the APPLET tag in your HTML page to accomodate a Jar file is simple. The Jar
file on the server is identified by the ARCHIVE parameter, where the directory location of
the jar file should be relative to the location of the html page:
<applet code=Animator.class
archive="jars/animator.jar"
width=460 height=160>
<param name=foo value="bar">
</applet>
Note that the familiar CODE=myApplet.class parameter must still be present. The CODE
parameter, as always, identifies the name of the applet where execution begins. However, the
class file for the applet and all of its helper classes are loaded from the Jar file.

Th ARCHIVE attribute describes one or more Jar files containing classes and other resources
that will be "preloaded". The classes are loaded using an instance of an AppletClassLoader
with the given CODEBASE. It takes the form archive = archiveList. The archives in
archiveList are separated by ",".

Once the archive file is identified, it is downloaded and separated into its components. During
the execution of the applet, when a new class, image or audio clip is requested by the applet,
it is searched for first in the archives associated with the applet. If the file is not found
amongst the archives that were downloaded, it is searched for on the applet's server, relative
to the CODEBASE (that is, it is searched for as in JDK1.0.2).

The archive tag may specify multiple Jar files. Each Jar file must be separated by ","
(comma). Each file is downloaded in turn:

<applet code=Animator.class
archive="classes.jar , images.jar , sounds.jar"
width=460 height=160>
<param name=foo value="bar">
</applet>
There can be any amount of white space between entries within the archive parameter. In
addition, the archive tag itself is case-insensitive; it can be lower-case, upper-case, or any
combination of lower- and upper-case letters, such as ArCHiVe.

Executable Jar Files


On Microsoft Windows systems, the Java 2 Runtime Environment's installation program will
register a default association for Jar files so that double-clicking a Jar file on the desktop will
automatically run it with javaw -jar. Dependent extensions bundled with the application
will also be loaded automatically. This feature makes the end-user runtime environment
easier to use on Microsoft Windows systems.

The Solaris 2.6 kernel has already been extended to recognize the special "magic" number
that identifies a Jar file, and to invoke java -jar on such a Jar file as if it were a native
Solaris executable. A application packaged in a Jar file can thus be executed directly from the
command line or by clicking an icon on the CDE desktop.

You might also like