205

Is there a good tool that can help to reverse engineer Java classes to UML that will show an overview of how my classes are related to each other? It doesn't need to decompile from JAR file because I have the sources. I know there are quite a few out there but most of those can only generate individual class. I hope there is a tool that can generate class diagram that shows an overview of how all my current classes and packages work together, so that I can analyse my current architecture design. Of course, analysing is one thing. The other is for documentation purposes.

I know of a few so far. But they cannot do an overview class diagram. Here's a list of Java UML tool that I have tried and is capable of doing reverse engineer but cannot do an overview class diagram of my whole project:

  • StarUML (Really good Opensource UML tool but cannot generate not overview class diagram)
  • ArgoUML (It is slow and sluggish and it keeps crashing)
  • UModel (This is a commerical software. I used before some time ago but found it difficult to use)
  • MS Visio (It doesn't support Java UML reverse engineer. Only for VB)

Are there any other recommendations to add to this list? And hopefully, can generate an overview Java class diagram. I am using Eclipse, by the way.

Kamil
  • 11,919
  • 23
  • 72
  • 160
Carven
  • 12,832
  • 24
  • 97
  • 139
  • 1
    Just to add a few more possibilities, in Eclipse, there is Papyrus. But the code generation plugin, sadly, didn't work for me. It has too many dependencies to install. I used eUML2 in the end. – Carven May 29 '11 at 12:08
  • You can check out UML Lab - it's commercial - but it has very sophisticated and customizable reverse engineering (and round-trip). – Christian Sep 14 '12 at 08:47
  • There's a free tool called [JGrasp](http://www.jgrasp.org/) which may help. – HRJ May 09 '14 at 07:39
  • I've been using this method: https://www.youtube.com/watch?v=HwBep8DmBVw only downside is: it's not free but you can have a 30 day trial, which was enough in my case. NOTE: It's not my video, I just found it while googling. – dazito Sep 22 '14 at 21:44
  • @Carven, please let me know which plugin did you use? Currently I am looking for generating sequence diagrams automatically on execution of junit/test. – User27854 Apr 18 '15 at 15:52
  • @user2900314 You should refer to my earlier comments. – Carven Apr 20 '15 at 14:34
  • http://www.objectaid.com/ works great for me. – Mr. AJ May 12 '15 at 22:32
  • IntelliJ IDEA Ultimate has this feature in the latest versions. – Elrond_EGLDer Jan 14 '16 at 18:44
  • I answered a similar Q here http://stackoverflow.com/a/39018106/711855 with a mvn plugin I developed – juanmf Aug 21 '16 at 15:36
  • UMlet can also do it: http://www.umlet.com/ – Martin Meeser Jan 06 '17 at 20:49
  • http://www.zenuml.com does not generate UML diagrams from Java code directly, but its DSL is Java-like. BTW I created zenuml :) It is free. – Devs love ZenUML Jul 21 '17 at 13:45
  • [binarydoc](https://github.com/fuiny/binarydoc-docker-compose) is a **Free** tool which can generate diagram from the Java `bytecode` directly, it can generate `UML hierarchy diagrams`, `UML class diagram`, `Class Cross-reference diagram`, Java code `Control flow diagram`, Java code `UML sequence diagrams`, etc. There is a sample UML diagram for the class [java.net.DatagramSocket](https://openjdk.binarydoc.org/net.java/openjdk/13.0/classfile?classfilelocation=java.net.datagramsocket) – Happy Mar 07 '20 at 23:38
  • for ea use - https://www.youtube.com/watch?v=cJwB5qxYDuU – Amruth A Apr 14 '20 at 15:14

4 Answers4

119

I wrote Class Visualizer, which does it. It's free tool which has all the mentioned functionality - I personally use it for the same purposes, as described in this post. For each browsed class it shows 2 instantly generated class diagrams: class relations and class UML view. Class relations diagram allows to traverse through the whole structure. It has full support for annotations and generics plus special support for JPA entities. Works very well with big projects (thousands of classes).

Fund Monica's Lawsuit
  • 5,770
  • 8
  • 46
  • 65
Jonatan Kaźmierczak
  • 1,591
  • 2
  • 12
  • 8
  • 10
    The program is really good. Thanks for creating it and for the link. – Igor Rodriguez Sep 08 '14 at 10:45
  • 1
    +1 for being free, stand-alone, cross-platform (just a Java program), actively maintained. Additional note: The program cannot read the source code directly, but works on class/jar files. Thus, compilation required. – bluenote10 Sep 20 '14 at 16:27
  • 20
    Jonatan, as an act of courtesy one could/should add a disclaimer to the answer when suggesting products, services etc one is involved in. – dbm Oct 15 '14 at 12:51
  • I downloaded this tool. Please specify how to use this tool. How to create associations between classes. – AndroidDev Dec 24 '14 at 08:23
  • @256, where you able to use Class visualizer tool. if so please help.. – User27854 Apr 18 '15 at 15:50
  • Does the class diagram show Aggregation and composition too? – DesirePRG Apr 27 '15 at 07:10
  • 1
    I should mention that as of today, eUML2 does not offer a free version for Eclipse Mars. Therefore, I went for Class Visualizer. It does the job but falls well short of greatness (not too many options, no customizations, shows all the primitives while I would like them to be ignored etc) – Aditya K Mar 14 '16 at 07:20
  • 2
    This is seriously cool. Given our decades old, very complex project -- much of the code is JDK 1.1 vintage -- this provides a great overview of how things are connected. As a supplement to the source code and Javadoc, it provides tremendous value at an awesome price. – gerardw Mar 21 '16 at 15:25
  • 2
    Is Class Visualizer an outstanding increadible useful tool? YES IT IS. How do we pay for it? It is free to download! How do we learn to use it? Spent 10 mins watching the video! – Martin Meeser Jan 06 '17 at 20:45
  • 2
    I have a class that calls a method of another class on the same project/folder, but that other class is not showing up. I added all dependencies possible, including all jdk8 jars. did I miss something? – Aquarius Power Mar 29 '17 at 13:23
  • 1
    A very good tool. Thanks for answering this question. – virusrocks Apr 28 '17 at 04:50
  • 1
    Fixed your answer to no longer be [spam](https://stackoverflow.com/help/promotion). In the future, do it on your own. – Fund Monica's Lawsuit Dec 05 '18 at 07:12
  • I am unable to use this tool - always gives me an error - 2019-07-03 18:25:06.404 WARNING Problem during importing class: org.springframework.aop.aspectj.TypePatternClassFilter java.lang.ClassNotFoundException: org.aspectj.weaver.tools.TypePatternMatcher 2019-07-03 18:25:06.41 WARNING Problem during importing class: org.springframework.aop.aspectj.AspectJMethodBeforeAdvice java.lang.ClassNotFoundException: org.aspectj.lang.JoinPoint – Matt Jerry Jul 03 '19 at 13:16
  • I have a sample application and I have some class files. Even if I give the exact class file with the full qualified path - it says class not found. I have seen the demo but unable to crack this. can someone help – Matt Jerry Jul 03 '19 at 13:18
  • Does this allow to choose a directory with source files and generate class diagram from the complete source? – Vivek Oct 27 '20 at 09:07
47

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

June7
  • 14,737
  • 7
  • 20
  • 31
Heisenbug
  • 37,414
  • 27
  • 126
  • 181
  • Does the free edition have this feature? – Carven May 29 '11 at 11:14
  • yes. I use free edition. – Heisenbug May 29 '11 at 11:15
  • 1
    Thanks! ;) I didn't try it because I always thought the free version has no code to UML generation. – Carven May 29 '11 at 12:07
  • Does eUML2 work with Android and does it generate sequence diagrams? – Quasaur Mar 07 '13 at 03:58
  • eUML2 works with eclipse and java in general (maybe other languages too). So yes, it should works if you are devoping an android app too. I don't remeber exactly about sequence diagram, It's a lot of time that I don't code in java anymore. I think yes, but why don't you check it by your self ;) – Heisenbug Mar 07 '13 at 07:48
  • 40
    It sucks. Hard. Instructions want users to prefix all properties with an 'f' char to sniff them. It is destructive, too, and adds a bunch of its own comments to ALL class files. Also, instructions are non-intuitive. If someone can refute my experience (based on the current version in Kepler), please do so. And, only three weeks of trial. Uninstalling now. – ingyhere May 17 '14 at 02:48
  • no free editions anymore for current eclipse versions. bummer. – rfreytag Sep 03 '15 at 10:02
  • The tool can not be used with Eclipse version Mars (yet?). – Christian St. Jan 09 '16 at 14:55
  • 1
    ı didn't like it. Its not compatible latest version of eclipse/oxygen. – Tayfun Yaşar Jan 11 '18 at 07:59
2

I´d say MoDisco is by far the most powerful one (though probably not the easiest one to work with).

MoDisco is a generic reverse engineering framework (so that you can customize your reverse engineering project, with MoDisco you can even reverse engineer the behaviour of the java methods, not only the structure and signatures) but also includes some predefined features like the generation of class diagrams out of Java code that you need.

Jordi Cabot
  • 7,432
  • 2
  • 27
  • 37
2

How about the Omondo Plugin for Eclipse. I have used it and I find it to be quite useful. Although if you are generating diagrams for large sources, you might have to start Eclipse with more memory.

Swaranga Sarma
  • 12,215
  • 19
  • 54
  • 87