3

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?

2
  • 1
    Writing JavaDocs Commented Jan 11, 2012 at 15:21
  • Adding Java doc might help. It used to work with Netbeans, not sure if it will in Eclipse though. Commented Jan 11, 2012 at 15:22

3 Answers 3

3

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.

Sign up to request clarification or add additional context in comments.

Comments

3

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

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.