Including images in javadocs

As you didn't show any sources, I can only do a glass-ball guess ...

For any files which are needed for documentation purposes, one should put them in a subdirectory named doc-files of your package directories. These will then be simply copied by Javadoc to the output directory. Then use a relative path in the <img> element.

I'm not sure if your IDE's Javadoc renderer will do the same, but it is worth a try.


A bit far fetched, but you can inline the images in the documentation by converting them into Base64. It would look like this:

<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIA..." />

There are online tools available to do the conversion:

  • http://www.base64-image.de
  • http://daturi.me
  • http://www.freeformatter.com/base64-encoder.html

With Eclipse Luna the following works for me.

  • com
    • company
      • somepackage
        • doc-files
          • image.png
        • Test.java

Now in Test.java's javadoc:

/**
 * <img src="./doc-files/image.png" />
 */

And Eclipse shows the image both in popup help, when you hover the mouse, and in the Javadoc View.

You can even add style="width: 100%;" to the img tag, so the image adjusts to the view/popup size.