How to Generate Uml Diagrams (Especially Sequence Diagrams) from Java Code

How to generate class diagrams and sequence diagrams from existing code?

IMO, generating UML diagrams for code that you have written yourself is kind of pointless. The value of UML is as a design aid and to a lesser extent as a reverse engineering aid. If you are intent on generating code documentation for existing well-understood code, Javadoc is probably better value than UML, and a lot less work.

The other problem is that generated UML class diagrams tend to be ugly because they tend to include more detail than is necessary, and because you need a human eye to lay things out decently. The same probably goes for sequence diagrams.

But if that hasn't convinced you, these links should help you do it.

  • UML Diagrams for NetBeans 7.0

  • Generating UML From the NetBeans IDE

(Disclaimer: scraped from this closed Question - UML automated generation for Netbeans 7.1)

Finally I need to take the generated GUI as an image.

Take a screen shot of the GUI using the tools provided by your OS.

How can I generate class diagrams from Java code that can be used to create new sequence diagrams

Enterprise Architect by Sparx can generate sequence diagrams for you, but it means running the code inside the UML tool.

Just about every tool I know of can generate class diagrams for you, of varying fidelity, but sequence diagrams are another animal. You have to tell it where the flows start. I don't see how a tool will read your mind. Doubly so if there's a UI involved. You don't have every JSP in a web app represented as UML, do you? What if you're just using straight HTML pages and no JSPs?

Personally, I don't find sequence diagrams to be all that useful. They lose their value once they exceed a certain level of complexity, as do all diagrams.

UPDATE: If EA is too pricey for you, I'd recommend JUDE (now Astah). The community edition used to be quite good - it even did Java import and diagram generation. Now I see that it's been stripped of that capability. A professional license for Astah is still only $280.

Java code which creates UML diagrams

Take a look at http://en.wikipedia.org/wiki/List_of_Unified_Modeling_Language_tools.

Some of the tools listed are in Java, some of them are open source and some of them are able to create UML diagrams in the XMI format.

If you want something light-weight, then Doxygen together with Graphviz can both reverse-engineer Java source code and automatically generate class diagrams with UML_LOOK

Generate UML Class Diagram from Java Project

I use eUML2 plugin from Soyatec, under Eclipse and it works fine for the generation of UML giving the source code. This tool is useful up to Eclipse 4.4.x



Related Topics



Leave a reply



Submit