Re: Python tools to manipulate JARs ?



On Jan 31, 1:50 pm, Laszlo Nagy <gand...@xxxxxxxxxxxxxxxxxx> wrote:
Andy Dingley írta:> I run build processes for a Java shop using Python (and some Ant).

Would anyone care to suggest favoured tools for manipulating the
innards of JARs? Or do I just treat them as plain zipfiles and get
stuck right in there?

Mainly I'm trying to query lists of classes and their embedded
versions and do some library dependency reporting. Performance speed
is starting to be an issue, as there's 1500+ classes in this bucket
and it's an interactive query.

I believe that you can rename any jar file to .zip and use zip tools to
list its contents.

Laszlo


To print out the classes you can use zipfile
it will list the contents of a jar file also


import zipfile

zf = zipfile.ZipFile("some.jar")

for info in zf.infolist():
print info.filename

Or print to a file

import zipfile

zf = zipfile.ZipFile("some.jar")

for info in zf.infolist():
classes = info.filename
myfile = file("classes.txt", 'w')
print >> myfile, classes


Enjoy
-Rob Marchetti

.



Relevant Pages

  • Re: Can I open a zip file thats within a jar file?
    ... ZipEntries appear to be a 'long' index into a native directory of zip entries. ... Since I want to randomly read each of the sound bites, i think it would work out much better if the SoundBites.zip file in the jar be copied to a temp file - once. ... Apparently you cant open a zipfile by simply doing "new ZipFile)" ...
    (comp.lang.java.programmer)
  • Re: Does it possible to include a jar in jar?
    ... eclifeww@yahoo.com (Earth) writes: ... > It is said that a jar could contains another jar. ... In the sense that a zipfile can contain another zipfile. ... java.util.zip.* classes) to load a class file. ...
    (comp.lang.java.programmer)
  • Re: List JAR files in WebStart
    ... Each JAR file contains a VersionInfo.xml file in the ... ZipFile zf = new ZipFile; ...
    (comp.lang.java.programmer)
  • Re: String Resources
    ... > programmer was utimately storing all this info in a zipfile, ... > apparently the application unzips this when running to get the ... especially when you need to support multiple languages? ... a jar file, ...
    (comp.lang.java.help)
  • Re: Can I open a zip file thats within a jar file?
    ... U. George wrote: ... > I'd like to open a zip file of sound bites. ... > jar file. ... Apparently you cant open a zipfile by simply doing "new ...
    (comp.lang.java.programmer)