Home » Software Development » Class diagram generation from Java source

About Abhishek Jain

Abhishek Jain
Abhishek is a lead software engineer with Impetus Technologies, pioneered in outsource product development. He has technical expertise in designing and implementing solutions around distributed application, database technologies, middle-ware technologies and SaaS platform.

Class diagram generation from Java source

UMLGraph allows the declarative specification and drawing of UML class and sequence diagrams. The specification is done in text diagrams, that are then transformed into the appropriate graphical representations.
UMLGraph is implemented as a javadoc doclet (a program satisfying the doclet API that specifies the content and format of the output generated by the javadoc tool). Furthermore, the output of UMLGraph needs to be post-processed with the Graphviz dot program. Therefore, to draw class diagrams with UMLGraph class you will need to have javadoc and Graphviz installed on your computer.

Maven plugin details

UMLGraph can be easily integrated with existing maven based application. Below is the maven plugin details which needs to be configured:

    <additionalparam>-horizontal -attributes -enumconstants -enumerations -operations -types -visibility -inferrel -inferdep -hide java.* -inferrel -collpackages java.util.*</additionalparam>

UMLGraph depends upon Graphviz which must be already installed on the machine. Also in the above maven setting if you configure ‘GRAPHVIZ_HOME’ environment variable you need not specify the docletpath in plugin details.

Steps to configure UMLGraph

  1. Download and install Graphviz
  2. Set GRAPHVIZ_HOME environment variable.
  3. Add the above plugin details in your POM.xml, configure additionalparams per your need.
  4. execute ‘mvn javadoc:javadoc’.


Below is the sample generated using above configuration over our Pizza entity pizza_class_diagram.png

More configuration

You can configure this diagram per your needs. Please refer UMLGraph class diagram options for more configuration.

Reference: Class diagram generation from Java source from our JCG partner Abhishek Jain at the NS.Infra blog.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
Email address:

Leave a Reply

Be the First to Comment!

Notify of