Creating Jars Using JarMaster's Programming Interface

JClass JarMaster provides a programming interface for creating JARs. Simply instantiate an object of type com/klg/jclass/jarmaster/JarTask, set some properties on the object, and call its buildJar() method.

Property Type Description
exclusions ArrayList A list of packages and classes to exclude from the JAR. One can use the methods addExclusion() and removeExclusion() to respectively add and remove exclusions.
classpath String The path to use to search for files and for dependencies. By default, the current system classpath is used, which is accessed via System.getProperty("java.class.path").
manifestFiles ArrayList The list of manifest files to use. One can use the methods addManifestFile() and removeManifestFile() to respectively add and remove manifest files.
includeDefaultExclusions boolean If true, the list of packages to exclude (see exclusions property) are initialized to the default list ("java/", "javax/", "com/sun/java/", "com/sun/image").
compressionLevel int The level of compression for the JAR. An integer between 0 (no compression) and 9 (max compression).
mainClass String The name of the class in the JAR to use as a main class (for executable JARs).
files String[] A list of filenames to be included in the JAR. These files and their dependencies must be accessible through the classpath.
jarName String The name of the output JAR.
jarFile File The output jar given as a File. If this property is null, the jarName will be used to get a JAR file. This property is null by default.
createJar boolean If true, a JAR is created; if false, a zip file is created. Default is true.

You can also use the JarTask class to update a JAR, compare JARs, and list a JAR. Please see the JarMaster API reference documentation for more information on using the JarTask class.