简体   繁体   中英

How to generate JavaDoc documentation for classes in a .jar file that I don't have the source code for?

I want to generate the API for all the classes that are there in my Java 1.6 application. It should look like regular Java 1.5 API documentation.

I don't have the source code. I have class files in a jar file.

You can't produce Javadoc from jars of class files, not even rudimentary Javadoc. You can only generate Javadoc from source files, because that is where the Javadoc lives.

I haven't used it, but this opensource project claims to create docs from java class or jar files:

http://classdoc.sourceforge.net/

You can use the javap command on any class in your classpath. This will not produce Javadoc files, but it will allow you to see what the class provides.

Ex...

javap java.lang.String produces the following output

public final class java.lang.String implements java.io.Serializable, java.lang.Comparable<java.lang.String>, java.lang.CharSequence {
  public static final java.util.Comparator<java.lang.String> CASE_INSENSITIVE_ORDER;
  public java.lang.String();
  public java.lang.String(java.lang.String);
  public java.lang.String(char[]);
  public java.lang.String(char[], int, int);

...and after a bunch of constructors there are other methods...

  public int length();
  public boolean isEmpty();
  public char charAt(int);
  public int codePointAt(int);

And you can have it show you other things too, but this is probably the most helpful.

Not exactly what you are looking for, but if you just have a jar with a bunch of classes this might be your best option.

Who is changing my question ? I don't have the source code. I have class files in a jar file. Purushotham 47 mins ago

You don't have any source files? Well then you're probably out of luck. There might be some obscure plugin buried in Eclipse's huge database that can do it from class files, but even then you're only going to get method signatures, not any comments.


However, if this is your project that you have written then you can generate JavaDoc in your IDE. For Eclipse do Project > Generate JavaDoc. In NetBeans, right click your project and select Generate JavaDoc.

If you're wanting to include your dependencies, then that's a very bad idea. Always link to your dependencies' JavaDocs, never include it in yours. If not for losing your sanity at seeing a massive wall of classes from Large Overly Framework X, it's just to keep them separate. If I want to read the JavaDoc on your project, I want to read it only on your project, not on slf4j.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM