title: How to include images into javadoc and reference them
body: <p>I checked the <a href="http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javadoc.html#sthref86" rel="nofollow noreferrer">manual of javadoc</a>  and read some posts here on stackoverflow (for example <a href="https://stackoverflow.com/questions/10779169/including-images-in-javadocs">Including images in javadocs</a>) but was unable to get a satisfactory result</p>
  
  <p>I want to provide an image inside my javadoc that should be packaged with the created html. Here are the steps I take:</p>
  
  <ul>
  <li>create a <code>doc-files</code> directory below <code>src/main/java</code> (this is a gradle project in STS)</li>
  <li>place a file named <code>classhierarchy.png</code> into the freshly created directory</li>
  <li>add <code>&lt;img src="doc-files/classhierarchy.png"&gt;</code> to the javadoc of my class <code>de.company.some.more.levels.MyClass</code></li>
  <li>create the javadoc</li>
  </ul>
  
  <p>I can see that the png file gets copied to C:\temp\NameOfProject\doc\doc-files but it can't be displayed because the img-link is relative to the package:
  c:/temp/NameOfProject/doc/de/company/some/more/levels/doc-files/classhierarchy.png</p>
  
  <p>I know that I could fix this by prefixing the path with many /../../ but I would have to adapt this if the package depth changes:</p>
  
  <pre><code>&lt;img src="../../../../../../doc-files/classhierarchy.png"&gt;
  </code></pre>
  
  <p>The second thing I don't like is the fact that directory doc-files is in the same path my source code is.</p>
  
  <p>How can I link and provide the images elegantly ?</p>