public class JarMaker
extends java.lang.Object
In addition, JarMaker can also be used to:
A JarMaker object can be included in the user's program, or JarMaker can be run as a command line program, as follows:
java utilities.JarMaker [ options ]
-source
sourceJarFile
-source
) is optional.
The -source option may be abbreviated to -s.
-destination
destinationJarFile
"Small"
to the
source file name. For example, if the source file is myfile.jar
,
then the default destination file would be myfileSmall.jar
.
-fileRequired
jarEntry1[,jarEntry2[...] ]
com/ibm/as400/access/DataQueue.class
.
The -fileRequired option may be abbreviated to -f.
-fileExcluded
jarEntry1[,jarEntry2[...] ]
com/ibm/as400/access/DataQueue.class
.
The -fileExcluded option may be abbreviated to -fx.
-additionalFile
file1[,file2[...] ]
-additionalFilesDirectory
baseDirectory
foo.class
in package com.ibm.mypackage
is located in directory
C:\dir1\subdir2\com\ibm\mypackage\
, then specify base directory C:\dir1\subdir2
.
-package
package1[,package2[...] ]
com.ibm.component
.
-packageExcluded
package1[,package2[...] ]
com.ibm.component
.
-extract
[baseDirectory]
-additionalFile
,
-additionalFilesDirectory
, and -destination
are ignored.
The -extract option may be abbreviated to -x.
By default, no extraction is done.
The default base directory is the current directory.
-split
[splitSize]
myfile.jar
,
then the destination JAR files would be
myfile0.jar
, myfile1.jar
, and so on.
When this option is specified, all other options except
-source
and -verbose
are ignored.
The -split option may be abbreviated to -sp.
The default split size is 2 megabytes (2048 kilobytes).
-verbose
-help
At least one of the following options must be specified:
If the following options are specified multiple times in a single command string, only the final specification applies:
Suppose the source JAR file is named myJar.jar
,
and is in the current directory.
To create a JAR file that contains only the classes
mypackage.MyClass1
and
mypackage.MyClass2
, along with their dependencies,
do the following:
import utilities.JarMaker; // Set up the list of required files. Vector classList = new Vector(); classList.addElement ("mypackage/MyClass1.class"); classList.addElement ("mypackage/MyClass2.class"); JarMaker jm = new JarMaker(); jm.setFilesRequired (classList); // Make a new JAR file, that contains only MyClass1, MyClass2, // and their dependencies. File sourceJar = new File ("myJar.jar"); File newJar = jm.makeJar (sourceJar); // smaller JAR file
Alternatively, the above action can be performed directly from the command line as follows:
java utilities.JarMaker -source myJar.jar -fileRequired mypackage/MyClass1.class,mypackage/MyClass2.class
Constructor and Description |
---|
JarMaker()
Deprecated.
Constructs a JarMaker object.
|
Modifier and Type | Method and Description |
---|---|
void |
addJarMakerListener(JarMakerListener listener)
Deprecated.
Adds a listener to the listener list.
|
java.io.File |
extract(java.io.File sourceJarFile)
Deprecated.
Extracts the desired entries and their dependencies from
the specified JAR or ZIP file.
|
void |
extract(java.io.File sourceJarFile,
java.io.File outputDirectory)
Deprecated.
Extracts the desired entries and their dependencies from
the specified JAR or ZIP file.
|
java.util.Vector |
getAdditionalFiles()
Deprecated.
Returns the additional files that are to be included in
the destination JAR or ZIP file.
|
java.util.Vector |
getFilesExcluded()
Deprecated.
Returns the names of the required files specified by the user.
|
java.util.Vector |
getFilesRequired()
Deprecated.
Returns the names of the required files specified by the user.
|
java.util.Vector |
getPackages()
Deprecated.
Returns the names of the packages that are to be included in the output.
|
java.util.Vector |
getPackagesExcluded()
Deprecated.
Returns the names of the packages that are to be excluded from the output.
|
java.util.Vector |
getRequiredFiles()
Deprecated.
Use getFilesRequired() instead.
|
static void |
main(java.lang.String[] args)
Deprecated.
Performs the actions specified in the invocation arguments.
|
java.io.File |
makeJar(java.io.File sourceJarFile)
Deprecated.
Generates a smaller JAR or ZIP file, containing only the desired entries
and their dependencies.
|
void |
makeJar(java.io.File sourceJarFile,
java.io.File destinationJarFile)
Deprecated.
Generates a smaller JAR or ZIP file, containing only the desired entries
and their dependencies.
|
void |
removeJarMakerListener(JarMakerListener listener)
Deprecated.
Removes a listener from the listener list.
|
void |
reset()
Deprecated.
Resets the JarMaker object to a clean, default state,
to facilitate object reuse.
|
void |
setAdditionalFiles(java.util.Vector fileList)
Deprecated.
Specifies additional files to include in the destination JAR or ZIP file.
|
void |
setAdditionalFiles(java.util.Vector fileList,
java.io.File baseDirectory)
Deprecated.
Specifies additional files to include in the destination JAR or ZIP file.
|
void |
setFilesExcluded(java.util.Vector entryList)
Deprecated.
Specifies the names of entries in the source JAR or ZIP file that are to be excluded from the target.
|
void |
setFilesRequired(java.util.Vector entryList)
Deprecated.
Specifies the names of required entries in the source JAR or ZIP file.
|
void |
setPackages(java.util.Vector packages)
Deprecated.
Specifies the names of packages that are to be included in the output.
|
void |
setPackagesExcluded(java.util.Vector packages)
Deprecated.
Specifies the names of packages that are to be excluded from the output.
|
void |
setRequiredFiles(java.util.Vector entryList)
Deprecated.
Use setFilesRequired() instead.
|
void |
setVerbose()
Deprecated.
Sets
verbose mode 'on'. |
void |
setVerbose(boolean verbose)
Deprecated.
Sets
verbose mode on or off. |
java.util.Vector |
split(java.io.File sourceJarFile)
Deprecated.
Splits the specified JAR or ZIP file into smaller JAR or ZIP files
whose size does not exceed 2 megabytes.
|
java.util.Vector |
split(java.io.File sourceJarFile,
int splitSizeKbytes)
Deprecated.
Splits the specified source JAR or ZIP file into smaller JAR or ZIP files
whose size does not exceed the specified number of kilobytes.
|
public void addJarMakerListener(JarMakerListener listener)
listener
- The listener.public java.io.File extract(java.io.File sourceJarFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
sourceJarFile
- The source JAR or ZIP file.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing the extracted files.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file.public void extract(java.io.File sourceJarFile, java.io.File outputDirectory) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
sourceJarFile
- The source JAR or ZIP file.outputDirectory
- The directory under which to put the extracted files.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing the extracted files.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file.public java.util.Vector getAdditionalFiles()
java.io.File
objects.public java.util.Vector getRequiredFiles()
public java.util.Vector getFilesRequired()
String
objects.public java.util.Vector getFilesExcluded()
String
objects.public java.util.Vector getPackages()
String
objects.public java.util.Vector getPackagesExcluded()
String
objects.public java.io.File makeJar(java.io.File sourceJarFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
sourceJarFile
- The source JAR or ZIP file.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing the destination file.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file
or writing the destination file.public void makeJar(java.io.File sourceJarFile, java.io.File destinationJarFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
sourceJarFile
- The source JAR or ZIP file.destinationJarFile
- The destination JAR or ZIP file.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing the destination file.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file
or writing the destination file.public void removeJarMakerListener(JarMakerListener listener)
listener
- The listener.public void reset()
public void setAdditionalFiles(java.util.Vector fileList)
fileList
- The additional files to include in the
destination JAR or ZIP file.
The list should contain only java.io.File
objects.public void setAdditionalFiles(java.util.Vector fileList, java.io.File baseDirectory)
fileList
- The additional files to include in the
destination JAR or ZIP file.
The list should contain only java.io.File
objects.baseDirectory
- The base directory for the specifed files. This path
is used when assigning a ZIP entry name for the additional file.
C:\dir1\subdir2\com\ibm\myproduct\MyClass.class
,
and class MyClass
is in package com.ibm.myproduct
,
then the base directory should be set to C:\dir1\subdir2
.public void setPackages(java.util.Vector packages)
com.ibm.component
.
The specified packages are simply included in the output.
No additional dependency analysis is done on the files in a package,
unless those files are also specified as required files.
packages
- The required packages.
The list should contain only String
objects.public void setPackagesExcluded(java.util.Vector packages)
com.ibm.component
.
packages
- The packages to be excluded.
The list should contain only String
objects.public void setRequiredFiles(java.util.Vector entryList)
entryList
- public void setFilesRequired(java.util.Vector entryList)
com/ibm/component/className.class
.
entryList
- The names of required JAR or ZIP entries.
The list should contain only String
objects.public void setFilesExcluded(java.util.Vector entryList)
com/ibm/component/className.class
.
entryList
- The names of JAR or ZIP entries to be excluded.
The list should contain only String
objects.public void setVerbose()
verbose
mode 'on'.public void setVerbose(boolean verbose)
verbose
mode on or off.verbose
- If true
, turn verbose mode on;
otherwise turn verbose mode off.public java.util.Vector split(java.io.File sourceJarFile) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
System.err
.sourceJarFile
- The source JAR or ZIP file.java.io.File
objects.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing a generated file.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file
or writing a generated file.public java.util.Vector split(java.io.File sourceJarFile, int splitSizeKbytes) throws java.io.FileNotFoundException, java.io.IOException, java.util.zip.ZipException
System.err
.sourceJarFile
- The source JAR or ZIP file.splitSizeKbytes
- The maximum size for the generated JAR or ZIP files
(in kilobytes). Must be greater than zero.java.io.File
objects.java.io.FileNotFoundException
- If the source file does not exist.java.io.IOException
- If an I/O error occurs when reading the source file
or writing a generated file.java.util.zip.ZipException
- If a ZIP error occurs when reading the source file
or writing a generated file.public static void main(java.lang.String[] args)
args
- The command line arguments.