linuxjarjavap

How to read a file from nested jar at Linux?


Is there any way to read some files from a jar inside the "outer" jar with javap command?

for example, I want to read the a.class

   A.jar
     |----/lib/
            |---B.jar
            |    |---/classes/
            |            |---a.class
            |            |---b.class
            |            |---c.class
            |---C.jar    

Solution

  • JAR files are ZIP files with a different extension. You can first extract the inner JAR, then use javap on it:

    unzip -p A.jar lib/B.jar > /tmp/B.jar
    javap -classpath /tmp/B.jar classes.a