15

I've created an API that I release as a JAR file. It's proprietary so I had to strip the source files out of it.

I currently include a separate /doc folder which contains the output of Eclipse's export-to-javadoc wizard. Not bad, but I'd like to go one step further.

I'd like to distribute the javadocs as a jar file that can be easily dropped into a future project which includes the jar file for my API. I know I've seen it done this way several times with other distributions I've used, but I haven't had any luck searching.

End goal is to allow future developers to have easy access to hover over comments and things of that nature.

Thanks!

Batman0730
  • 487
  • 2
  • 5
  • 21
  • At least for the second part of your question ... Here are detailed instructions on how to put JavaDocs in Eclipse http://stackoverflow.com/a/11579339/356895 – JJD Apr 01 '13 at 18:13

2 Answers2

11

It seems it is enough to package the doc folder containing the eclipse generated documentation as a jar file. Then if you want to use that jar as javadocs of the actual jar containing the compiled .class files, you assign the javadoc jar with the "Javadoc in archive" in Eclipse and set the Path within archive as doc. It seems Eclipse looks for index.html and package-list entries in the doc folder.

Setting Javadoc location in Eclipse

Also using maven-javadoc-plugin may an easy way to do this. See the link below:

http://www.avajava.com/tutorials/lessons/how-do-i-generate-and-deploy-a-javadoc-jar-file-for-my-project.html

suat
  • 4,239
  • 3
  • 28
  • 51
  • Thanks for the recommendation. I actually had stumbled across the javadoc maven plug-in, although I didn't want to introduce maven into a non-maven project. I'm going to look into more about what the plug-in is actually doing, and that may help me understand how to generate a javadoc jar without maven. Appreciate the help, I'll follow up with any other findings. – Batman0730 Aug 28 '11 at 02:16
  • @Batman0730 I have edited the answer. Could you please try the way I described? – suat Aug 28 '11 at 09:14
  • 1
    I think this clears up a misunderstanding I've had all along. You can't just drop these javadoc.jar files in a project and magically get comments attached to code. You have to manually attach javadocs to their libraries, even when they are in .jar format. I had never tested it before now, so my assumption was wrong all along. Thanks for your help. – Batman0730 Aug 29 '11 at 13:27
0

If your end goal is just for the future developers to be able to view your javadoc instructions when they are using your classes or methods, in Eclipse you can have option to export java source files when you export your jar library as shown in the image below:

enter image description here

This also allows developers to step in and view your codes while debugging.

Tony Vu
  • 4,251
  • 3
  • 31
  • 38