1

How could one export the outline of a Java class to a plain text file?

Something similar to the Outline View in Eclipse, but in a text file. Similar to extracting the interface, but suffeciently more basic.

I've tried to search for such a tool but couldn't find it. I would prefer if extracting the outline could be automated, eg. run the tool from a script.

n611x007
  • 8,952
  • 8
  • 59
  • 102

1 Answers1

1

I have found a built-in tool that comes close (bit of an overkill but works). Provided you can compile your program, you can use javap, the Java Class File Disassembler to extract the outline for a class. For example if you have FooBar.class, you can do

javap FooBar

to see the fields and methods at the package's visibility level or

javap -private FooBar

to see all of the outline. The docs have other options.

WARNING Ed Staub warns about potential caveats, you should expect that some situations, probably maybe annotations, inner classes, something like that would not be handled correctly.

Availability: I haven't checked, but the javap seems to be available at least since 1.5 JDK.

Community
  • 1
  • 1
n611x007
  • 8,952
  • 8
  • 59
  • 102