Java Utililty Methods Jar Usage

List of utility methods to do Jar Usage

Description

The list of methods to do Jar Usage are organized into topic(s).

Method

Pack200.Packer_getPacker()
get Packer
Pack200.Packer packer = Pack200.newPacker();
Map<String, String> p = packer.properties();
p.put(Pack200.Packer.EFFORT, "7"); 
p.put(Pack200.Packer.SEGMENT_LIMIT, "-1");
p.put(Pack200.Packer.KEEP_FILE_ORDER, Pack200.Packer.FALSE);
p.put(Pack200.Packer.MODIFICATION_TIME, Pack200.Packer.LATEST);
p.put(Pack200.Packer.DEFLATE_HINT, Pack200.Packer.FALSE);
p.put(Pack200.Packer.UNKNOWN_ATTRIBUTE, Pack200.Packer.ERROR);
...
DictionaryallocateReadOnlyDictionary(final Attributes attributes)
allocate Read Only Dictionary
return new Dictionary() {
    public int size() {
        return attributes.size();
    public boolean isEmpty() {
        return attributes.isEmpty();
    public Enumeration keys() {
...
DictionaryallocateReadOnlyI18nDictionary(final Attributes attributes, final ResourceBundle resourceBundle)
allocate Read Only In Dictionary
return new Dictionary() {
    public int size() {
        return attributes.size();
    public boolean isEmpty() {
        return attributes.isEmpty();
    public Enumeration keys() {
...
booleancheckJarValidity(String path)
Checks that file is valid jar archive
try {
    JarFile jar = new JarFile(path);
    jar.size();
} catch (Exception e) {
    return false;
return true;
booleancontainsClass(JarFile jarFile, String agentRunnerClassName)
contains Class
Enumeration<JarEntry> e = jarFile.entries();
while (e.hasMoreElements()) {
    JarEntry je = e.nextElement();
    if (je.isDirectory() || !je.getName().endsWith(".class")) {
        continue;
    String className = je.getName().substring(0, je.getName().length() - 6);
    className = className.replace('/', '.');
...
booleancontainsClass(JarFile jarFile, String classFilePath)
contains Class
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
    final JarEntry entry = entries.nextElement();
    if ((!entry.isDirectory()) && entry.getName().contains(classFilePath)) {
        return true;
return false;
...
MapconvertAttributes(Attributes attributes)
convert Attributes
Map result = new HashMap();
for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
    Attributes.Name key = (Name) iter.next();
    result.put(key.toString(), attributes.getValue(key));
return result;
PackercreatePacker()
create Packer
Pack200.Packer p = Pack200.newPacker();
SortedMap<String, String> props = p.properties();
props.put(Pack200.Packer.MODIFICATION_TIME, Pack200.Packer.KEEP);
props.put(Pack200.Packer.EFFORT, "0");
return p;
voidfindClassesByJar(String packageName, JarFile jar, final boolean recursive, Set> classes)
find Classes By Jar
String packageDirName = packageName.replace('.', '/');
Enumeration<JarEntry> jarEntries = jar.entries();
JarEntry jarEntry;
String name, className;
Class<?> claze;
while (jarEntries.hasMoreElements()) {
    jarEntry = jarEntries.nextElement();
    name = jarEntry.getName();
...
AttributesgetAttribute(String name, String value)
get Attribute
Attributes a = new Attributes();
Attributes.Name attribName = new Attributes.Name(name);
a.put(attribName, value);
return a;