How do I print the class structures in a jar file using the javap tool?

Solution 1:

#!/bin/bash
# Set the JAR name
jar=<JAR NAME>
# Loop through the classes (everything ending in .class)
for class in $(jar -tf $jar | grep '.class'); do 
    # Replace /'s with .'s
    class=${class//\//.};
    # javap
    javap -classpath $jar ${class//.class/}; 
done

Solution 2:

Even easier would be

JAR=<path to jarfile> \
javap -classpath $JAR $(jar -tf $JAR | grep "class$" | sed s/\.class$//)