1

How can i write a java program to retrieve and output the javadoc of a given class?

Input: java class say (classA)
Output: java doc of classA

Thanks

Sotirios Delimanolis
  • 274,122
  • 60
  • 696
  • 724
ams2705
  • 287
  • 2
  • 5
  • 17
  • unless you include your source or parsed javadocs then you won't get anything. they aren't included in class files http://stackoverflow.com/questions/4135070/do-your-javadocs-get-compiled-into-your-class-files – devshorts Feb 27 '14 at 22:16
  • I believe the class files are in binary form only. Only the source code java file contains all the comments required to generate a javadoc. You would need to have access to the source code file and programmatically run the javadoc.exe program. Assuming you had access to the source code, you could use ProcessBuilder to execute javadoc.exe and point it to the source code. – Alan Feb 27 '14 at 22:17

2 Answers2

0

Steps:

1. Download JAD

$ jad -o -ddecompiled_sources -sjava *.class

2. Generate the javadoc

$ javadoc -d generated_javadoc -sourcepath decompiled_sources -subpackages java -exclude java.net:java.lang

3. Done

EDIT: As seen on https://stackoverflow.com/a/8798013/3315914, comments are discarded in the compilation process, so you can generate the javadoc, but without comments.

Community
  • 1
  • 1
rpax
  • 4,468
  • 7
  • 33
  • 57
-1

No, because the Javadoc isn't in the .class file.

In any case why? Something wrong with your Web browser?

user207421
  • 305,947
  • 44
  • 307
  • 483