jjNford
jjNford

Reputation: 5270

Java API documentation

How can I add Java documentation to a .JAR file so that when people are using my JAR file and type '.' Eclipse will display the documentation for the available API's (intellisense).

MORE INFO

I have java doc created but when I export the jar file it does not contain intellisense when used in other projects. This is what I am having trouble with.

UPDATE The intellisense only shows up if the export the source. However I want to hide the source code. How can I get around this?

Upvotes: 3

Views: 620

Answers (3)

alan
alan

Reputation: 76

Maven has a very elegant way of handling this.

Step 1: The Maven way to generate javadocs: http://maven.apache.org/plugins/maven-javadoc-plugin/

Step 2: To ensure Eclipse always attaches these docs, use the maven-eclipse-plugin

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-eclipse-plugin</artifactId>
    <configuration>
      <downloadJavadocs>true</downloadJavadocs>
    </configuration>
</plugin>

Once these two steps are done, the consumers of your API jars will always have your latest javadocs with no further intervention

Upvotes: 3

Thiago Chaves
Thiago Chaves

Reputation: 9453

In Eclipse, export the project with sources.

Do File -> Export... -> Java -> JAR File -> Next

Then select the checkbox Export java source files and resources.

Then go on until the JAR is created.

Edit: after the edits in the question, this answer is no longer valid, but it is still useful.

Upvotes: 0

Pedantic
Pedantic

Reputation: 5022

If you don't want to include the entire source code with your .jar, you can zip/jar up just the javadocs (however you generate them.. I do it using the Project->Generate Javadoc menu option in Eclipse). An end user can then "attach" them to the referenced library in the project build path settings.

The javadoc location attribute of a project library can be a URL, a local directory or a local archive file.

After noticing your edits, I might want to mention that Ant has a javadoc task that can generate your javadocs during a build.

Upvotes: 3

Related Questions