November 5th, 2008 at 11:43 am

Java2Uml – generating UML2 class diagrams from existing code

The Eclipse UML2 project provides models and diagram editors for creating and editing UML models in Eclipse. The problem is that these models are not tied to code in any way, and in particular, if you want to visualize existing Java code in class diagrams, you have no option but to create the class diagram manually.

A former alternative, the Omondo EclipseUML Free Edition is not available for Eclipse 3.4 and other free tools (I have tried a lot) don’t work well, or not at alll, either.

Well, with the exception of the TOPCASED Java2UML Plugin, which is not easy to find and has not been updated for over 2 years now. However, I tried it with Eclipse Ganymede and it still works quite well in the current version as it is able to generate a UML2 model from Java code from which then a class diagram can be initialized and edited.

To install it, simply download the org.topcased.java.reverse_0.2.0.jar plugin and put it into your favourite dropin location (e.g. ${ECLIPSE_HOME}/eclipse/dropins/plugins). Then start Eclipse and make sure that all UML2 components are installed. Right-click on a Java Package in the Package Explorer and you should see the menu item UML from Java just above the Run as/Debug as submenu items. When selected, a wizard opens which lets you specify the target .uml file, which will be generated.

After the generation process you can simply choose Initialze Class Diagram from the .uml file’s context menu to visualize you classes. Note that you have to hide a lot of external classes and other information you don’t need, but doing this is much more efficient than creating the whole diagram by hand.

Leave a Comment

You must be logged in to post a comment.