Reputation: 116958
I'm looking for a few ideas to quickly generate an list of imports requires by a java class. Ideally this could be done using javap or some other tool found in the JDK.
I'm not interested in a GUI program because eventually I want to use the output for validating my build. Also, I don't want to hook in a large amount of binary code that has to be added into the build code. So the simpler the solution, the better.
Upvotes: 2
Views: 199
Reputation: 15104
This is quick and dirty, but may be good enough for what you want. Search for the class constants:
>javap -classpath ... -c -private -s -verbose grimbo.appengine.test.perf.Log | findstr /r /c:"const.#[0-9]*.=.class"
Gives:
const #3 = class #38; // java/lang/StringBuilder
const #11 = class #47; // grimbo/appengine/test/perf/Log
const #12 = class #48; // java/lang/Object
const #43 = class #54; // javax/servlet/ServletContext
const #45 = class #56; // java/io/PrintWriter
Upvotes: 3