Generate Javadoc with UML Diagrams

It is very useful to have UML Diagrams integrated into your javadoc – they give you a neat visual overview of the contents of you sourcecode. I want to show you how  to integrate this into an automated build. I implemented this with an ant target and my IDE Netbeans.

Add this to your build.xml in the root of your project:

You will need Graphviz and UMLGraph.

I had to execute sudo ln -s /usr/local/bin/dot /usr/bin/dot on my Mac OSX to make dot work. Since it was not recognized in my PATH and quitted with the error:

Cannot run program "dot": error=2, No such file or directory ensure that dot is in your path and that its path does not contain spaces


You can pass several arguments to UML Grap. You can find a full list on the website.


You can start build like this:

Run target
If everything works fine you will see:

Run target output

The javadoc is opened in your browser.


For convenience you can add a shortcut to build your javadoc and UML diagrams.

Bildschirmfoto 2015-03-25 um 22.23.48

Create Shortcut

Create Shortcut Menu Select Menu

Run "Generate Javadoc and UML Diagram"



If you have found a spelling error, please, notify us by selecting that text and pressing Ctrl+Enter.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Spelling error report

The following text will be sent to our editors: