ajar - Alternative Java(TM) archive

Synopsis

ajar {-h | --help}

ajar {-l | --list} [-v | --verbose] [-q | --quiet] jarfile [{file | pattern} ...] [{-x | -i} {file | pattern} ...] ...

ajar {-x | --extract} [-v | --verbose] [-q | --quiet] [-N | --neverWrite] [-p | --pipe] jarfile [{file | pattern} ... ]
[{-x | -i}
{file | pattern} ...] ...

ajar {-c | --create} [-0 | --store-only] [-v | --verbose] [-r | --recurse] [-@ | --stdin] [-D | --nodirs] [-q | --quiet]
[{-m | --manifest} mffile] [-M | --no-manifest] [{-n | --no-deflate} suffix..] jarfile file ... [{-x | -i} {file | pattern} ...] ...

ajar {-a | --add} [-0 | --store-only] [-v | --verbose] [-r | --recurse] [-@ | --stdin] [-D | --nodirs] [-q | --quiet]
[{-m | --manifest} mffile] [-M | --no-manifest] [{-n | --no-deflate} suffix..] jarfile file ... [{-x | -i} {file | pattern} ...] ...

ajar {-d | --delete} [-v | --verbose] [-q | --quiet] [{-m | --manifest} mffile] [-M | --no-manifest] jarfile {file | pattern} ... [{-x | -i} {file | pattern} ...] ...

Description

ajar may be used as an alternative interface for creating and manipulating Javatm Archive (JAR) files. The ajar utility combines several of the features found in zip/unzip tools with those of the IBM(R) Developer Kit for Java jar tool. Use ajar instead of the jar command when you need a zip or unzip like interface.

Like the jar tool, ajar lists the contents of jar files, extracts from jar files, creates new jar files and supports many of the zip formats.. Additionally, ajar supports adding and deleting files in existing jars.

Actions

-h | --help
Writes command syntax to stdout.
-l | --list
Writes table of contents to stdout.
-x | --extract
Extracts files to the current directory.
-c | --create
Creates a new archive.
-a | --add
Adds new files to the archive and replaces existing files.
-d | --delete
Deletes files from the archive.

Options

-@ | --stdin
Read file list from stdin. The file list consists of parameters that would normally follow the jarfile parameter on the command line. The file list may consist of multiple lines with one item per line and no leading blanks. Comments begin with '#' and extend to the end of the line.
-0 | --store-only
Store only. Do not compress/deflate files. Used when adding files and creating jars.
-m | --manifest
Include manifest information from the specified file.
-n | --no-deflate
Do not deflate files with the specified suffixes. The list of suffixes must be terminated by another option or "--". See examples below.
-p | --pipe
Extract to stdout.
-q | --quiet
Quiet mode. Do not write informational and warning messages.
-r | --recurse
Recurse into directories. Used when adding files and creating jars.
-v | --verbose
Verbose mode. Write diagnostic information to stderr.
-D | --nodirs
Suppress directory entries. Used when adding files and creating jars.
-M | --no-manifest
Do not create a manifest.
-N | --neverWrite
Never overwrite any files when extracting.

Operands

The jarfile operand specifies the pathname of the jar file being operated on. jarfile must be an Integrated File System (IFS) name.

The file operand specifies the pathname of a file or directory. file must be an IFS name.

The pattern operand specifies a pattern to match pathnames of files and directories. pattern will match to IFS names. A pattern is a sequence of characters containing one or more of the following meta characters:

*
matches 0 or more characters
?
matches any single character
[...]
matches any single character found within the brackets where "..." represents a set of characters. Ranges are specified by a beginning character, a hyphen, and an ending character. A exclamation ('!') or carrot ('^') following the left bracket means the characters within the brackets are complemented (match anything except the characters within the brackets).

Patterns must be contained within quotation marks or the meta characters must be preceded by a back slash ('\') to prevent Qshell from interpreting them.

The file and pattern operands are used to select the files to be acted upon. Selected files are determined using three sets of files, a candidate set, an exclusion set, and an inclusion set.

candidate set
The candidate set is determined using the operands listed after jarfile and before any -x or -i. For the list and extract actions the candidate set defaults to all files contained in the jar file. For all other actions there is no default value for the candidate set.
exclusion set
The exclusion set is determined using all lists of file and pattern operands preceded by a -x and followed by another -x, a -i or the end of the command string. The exclusion set defaults to the empty set.
inclusion set
The inclusion set is determined using all lists of file and pattern operands preceded by a -i and followed by another -i, a -x or the end of the command string. The inclusion set defaults to all files in the candidate set.

All candidate files are selected that are in the inclusion set and not in the exclusion set.

Exit Status

Examples
  1. To list all files in a jar file named myjar which is located in the current directory: ajar -l myjar
  2. To list all .java files in myjar: ajar -l myjar \*.java
  3. To extract all files from myjar into the current directory: ajar -x myjar
  4. To create a jar named myjar containing all directories and files in the file system hierarchy rooted in the current directory (Note in this example Qshell interprets the '*' and expands it so that the list of candidate files contains all files and directories in the current directory.): ajar -c -r myjar *
  5. To create a jar named myjar containing entries for only the files in the current directory: ajar -c -D myjar *
  6. To create the same jar file without a manifest (which is a zip file for all practical purposes): ajar -c -D -M myjar *
  7. To create a jar named myjar containing all files except .java files in the file system hierarchy rooted in the current directory: ajar -c -r myjar * -x \*.java
  8. To create a jar named myjar containing only the .class files in a file system hierarchy rooted in the current directory: ajar -c -r myjar * -i \*.class
  9. To create a jar named myjar without deflating the .java files: ajar -c -r -n java -- myjar *
  10. To create a jar named myjar while reading the file list from stdin: ajar -@ -c -r myjar

    Sample stdin data:

    docs
    source
    classes
    -x  
    docs/foo/*
    
  11. To add a file named bar to a jar named myjar: ajar -a myjar bar
  12. To delete a file named foo/bar from a jar named myjar: ajar -d myjar foo/bar
Notes
  1. Short options can be clustered (for example, -c -v -D is the same as -cvD). Long options (--create, --verbose, --nodirs, ..., and so on.) can be abbreviated as long as the abbreviations are unique.
  2. File names can be changed when creating a jar or adding a file to a jar. For example, "ajar -c x.jar bin/foo : bin/bar" creates the jar file x.jar from the file bin/foo with a single entry, bin/bar. This can also be done using stdin, "ajar -c@ x.jar", where stdin contains:
    bin/foo : bin/bar
    
  3. Use of ajar requires the QIBM_MULTI_THREADED environment variable must be set to 'Y'.