|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--utilities.JarMaker
The JarMaker class is used to generate a smaller (and therefore faster loading) JAR or ZIP file from a larger one, based on the user's requirements.
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
.
-requiredFile
jarEntry1[,jarEntry2[...] ]
com/ibm/as400/access/DataQueue.class
.
The -requiredFile option may be abbreviated to -rf.
-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
.
-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.setRequiredFiles (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 -requiredFile mypackage/MyClass1.class,mypackage/MyClass2.class
Constructor Summary | |
JarMaker()
Constructs a JarMaker object. |
Method Summary | |
void |
addJarMakerListener(JarMakerListener listener)
Adds a listener to the listener list. |
java.io.File |
extract(java.io.File sourceJarFile)
Extracts the desired entries and their dependencies from the specified JAR or ZIP file. |
void |
extract(java.io.File sourceJarFile,
java.io.File outputDirectory)
Extracts the desired entries and their dependencies from the specified JAR or ZIP file. |
java.util.Vector |
getAdditionalFiles()
Returns the additional files that are to be included in the destination JAR or ZIP file. |
java.util.Vector |
getPackages()
Returns the names of the packages that are to be included in the output. |
java.util.Vector |
getRequiredFiles()
Returns the names of the required files specified by the user. |
static void |
main(java.lang.String[] args)
Performs the actions specified in the invocation arguments. |
java.io.File |
makeJar(java.io.File sourceJarFile)
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)
Generates a smaller JAR or ZIP file, containing only the desired entries and their dependencies. |
void |
removeJarMakerListener(JarMakerListener listener)
Removes a listener from the listener list. |
void |
reset()
Resets the JarMaker object to a clean, default state, to facilitate object reuse. |
void |
setAdditionalFiles(java.util.Vector fileList)
Specifies additional files to include in the destination JAR or ZIP file. |
void |
setAdditionalFiles(java.util.Vector fileList,
java.io.File baseDirectory)
Specifies additional files to include in the destination JAR or ZIP file. |
void |
setPackages(java.util.Vector packages)
Specifies the names of packages that are to be included in the output. |
void |
setRequiredFiles(java.util.Vector entryList)
Specifies the names of required entries in the source JAR or ZIP file. |
void |
setVerbose()
Sets verbose mode 'on'. |
void |
setVerbose(boolean verbose)
Sets verbose mode on or off. |
java.util.Vector |
split(java.io.File sourceJarFile)
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)
Splits the specified source JAR or ZIP file into smaller JAR or ZIP files whose size does not exceed the specified number of kilobytes. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public JarMaker()
Method Detail |
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()
String
objects.public java.util.Vector getPackages()
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 setRequiredFiles(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 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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |