Class SuperJar
This class has a main
method, and is designed to be invoked
from the command line.
- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
Writes a new jar or zip file based on the contents of an existing jar file and the jar files referenced by its manifest.void
Writes the data from this object to a single jar file combining the contents of all the dependencies.void
Writes the data from this object to a zip file containing all the top-level and dependency jars as individual jar files in the same directory.
-
Constructor Details
-
SuperJar
public SuperJar(File[] jarFiles, File[] flatFiles, String[] jarExcludes, String[] entryExcludes) throws IOException Constructor.The
entryExcludes
values are full pathnames with no leading "/", interpreted as follows:- ending in "/": exclude that directory and all children
- ending in "/*": exclude all flat files, but not subdirectories of that directory
- otherwise: exclude the flat file with that exact name
- Parameters:
jarFiles
- top-level jar files containing files and dependenciesflatFiles
- files for inclusion at top level of outputjarExcludes
- names of jar files which may be named as class-path dependencies but which should not be included in the resultentryExcludes
- jar file entries which should be excluded from the result- Throws:
IOException
-
-
Method Details
-
writeSingleJar
Writes the data from this object to a single jar file combining the contents of all the dependencies.- Parameters:
out
- destination stream- Throws:
IOException
-
writeZipOfJars
Writes the data from this object to a zip file containing all the top-level and dependency jars as individual jar files in the same directory.- Parameters:
out
- destination stream- Throws:
IOException
-
main
Writes a new jar or zip file based on the contents of an existing jar file and the jar files referenced by its manifest.Usage:
SuperJar [-oj outjar] [-oz outzip] [[-xjar jar] -xjar jar ...] [[-xentry entry] -xentry entry ...] jarfile [jarfile ...]
If the
-oj
flag is given, it supplies the name of a monolithic jar file to output.-o
is a deprecated synonym for-oj
.If the
-oz
flag is given, it supplies the name of a zip file to output. This zip file will contain all the named and referenced jar files in a single flat directory.The
-xjar
flag may be supplied one or more times to define jarfiles which should not be included, even if they are referenced in the manifest's Class-Path entry of a jar file which is included. Theexclude
argument thus defined is the name, optionally with one or more prepended path elements of the jar file to be excluded (e.g. axis.jar or axis/axis.jar would both work).-x
is a deprecated synonym for-xjar
.The
-xent
flag may be supplied one or more times to give full paths for jar entries which should not be included in the output. These are interpreted as follows:- ending in "/": exclude that directory and all children
- ending in "/*": exclude all flat files, but not subdirectories of that directory
- otherwise: exclude the flat file with that exact name
The
jarfile
argument(s) will be combined to form the output file, all their contents and those of the jar files referenced in their Class-Path manifest entries will be used. The manifest of the first one will be used as the manifest of the output file (though its Class-Path entry will be empty). Zip files can be used as well, they work the same but have no manifest.Any
flat-file
arguments will be included as files at the top level of the output jar or zip file.- Parameters:
args
- an array of command-line arguments as described above- Throws:
IOException
-