<p>How can I generate UML diagrams (especially sequence diagrams) from existing Java code?</p>

[{'answer_id': 51864, 'author': 'prakash', 'author_id': 123, 'author_profile': 'https://Stackoverflow.com/users/123', 'pm_score': 5, 'selected': False, 'text': '<p>What is your codebase? Java or C++?</p>\n\n<p><a href="http://marketplace.eclipse.org/content/euml2-free-edition" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c8TO1.png" alt="alt text"></a></p>\n\n<blockquote>\n  <p>eUML2 for Java is a powerful UML modeler designed for Java developper\n  in Eclipse. The free edition can be used for commercial use. It\n  supports the following features:</p>\n  \n  <ul>\n  <li>CVS and Team Support</li>\n  <li>Designed for large project with multiple and customizable model views</li>\n  <li>Helios Compliant</li>\n  <li>Real-time code/model synchronization</li>\n  <li>UML2.1 compliant and support of OMG XMI</li>\n  <li>JDK 1.4 and 1.5 support</li>\n  <li><p>The commercial edition provides:</p></li>\n  <li><p>Advanced reversed engineering</p></li>\n  <li>Powerful true dependency analyze tools</li>\n  <li>UML Profile and MDD</li>\n  <li>Database tools</li>\n  <li>Customizable template support</li>\n  </ul>\n</blockquote>\n'}, {'answer_id': 114412, 'author': 'serg10', 'author_id': 1853, 'author_profile': 'https://Stackoverflow.com/users/1853', 'pm_score': 1, 'selected': False, 'text': '<p>By far the best tool I have used for reverse engineering, and round tripping java -> UML is <a href="http://www.borland.com/products/together/default.aspx" rel="nofollow noreferrer">Borland\'s Together</a>.  It is based on Eclipse (not just a single plugin) and really works well.</p>\n'}, {'answer_id': 732247, 'author': 'Vineet Reynolds', 'author_id': 3916, 'author_profile': 'https://Stackoverflow.com/users/3916', 'pm_score': 2, 'selected': False, 'text': '<p>I would recommend <a href="http://www.omondo.com" rel="nofollow noreferrer">EclipseUML from Omondo</a> for general usage, although I did experience some problems a few months back, with my web projects. They had a free edition at one point in time, but that is supposedly no longer promoted.</p>\n\n<p>If you are really keen on reverse engineering sequence diagrams from source code, I would recommend <a href="http://code.google.com/p/jtracert/" rel="nofollow noreferrer">jTracert</a>.</p>\n\n<p>As far as Eclipse projects themselves are concerned, the <a href="http://wiki.eclipse.org/MDT-UML2Tools" rel="nofollow noreferrer">Eclipse UML2 Tools</a> project might support reverse engineering, although I\'ve have never seen its use in practice.</p>\n\n<p>The <a href="http://www.eclipse.org/gmt/modisco/" rel="nofollow noreferrer">MoDisco</a> (Model Discovery) project Eclipse GMT project seems to be clearer in achieving your objective. The <a href="http://www.eclipse.org/gmt/modisco/technologies/" rel="nofollow noreferrer">list of technology specific tools</a> would be a good place to start with.</p>\n'}, {'answer_id': 824221, 'author': 'Patrick Cornelissen', 'author_id': 33624, 'author_profile': 'https://Stackoverflow.com/users/33624', 'pm_score': 2, 'selected': False, 'text': "<p>You could also give the netbeans UML modeller a try. I have used it to generate javacode that I used in my eclipse projects. You can even import eclipse projects in netbeans and keep the eclipse settings synced with the netbeans project settings.</p>\n\n<p>I tried several UML modellers for eclipse and wasn't satisfied with them. They were either unstable, complicated or just plain ugly. ;-)</p>\n"}, {'answer_id': 4007561, 'author': 'Zamel', 'author_id': 22158, 'author_profile': 'https://Stackoverflow.com/users/22158', 'pm_score': 3, 'selected': False, 'text': '<p>How about <a href="http://plantuml.sourceforge.net/" rel="noreferrer">PlantUML</a>?\nIt\'s not for reverse engineering!!! It\'s for engineering before you code.</p>\n'}, {'answer_id': 4884743, 'author': 'UML GURU', 'author_id': 294000, 'author_profile': 'https://Stackoverflow.com/users/294000', 'pm_score': 2, 'selected': False, 'text': '<p>You can use the 30 days evaluation build of EclipseUML for Eclipse 3.5 : <a href="http://www.uml2.org/eclipse-java-galileo-SR2-win32_eclipseUML2.2_package_may2010.zip" rel="nofollow noreferrer">http://www.uml2.org/eclipse-java-galileo-SR2-win32_eclipseUML2.2_package_may2010.zip</a>\nThis is not the latest 3.6 build, but is pretty good and don\'t require you purchase it for testing and reverse engineering.</p>\n\n<p>Reverse engineering : <a href="http://www.forum-omondo.com/documentation_eclipseuml_2008/reverse/reverse/reverse_engineering_example.html" rel="nofollow noreferrer">http://www.forum-omondo.com/documentation_eclipseuml_2008/reverse/reverse/reverse_engineering_example.html</a></p>\n\n<p>Live flash demo: <a href="http://www.ejb3.org/reverse.swf" rel="nofollow noreferrer">http://www.ejb3.org/reverse.swf</a></p>\n\n<p>EclipseUML Omondo is the best tool in the world for Java. Only eUML seems to compete with it on this live java synchronization market, but eUML adds model tags in the code which is really very very bad and a definitive no go for me.</p>\n'}, {'answer_id': 5818760, 'author': 'pcmind', 'author_id': 600207, 'author_profile': 'https://Stackoverflow.com/users/600207', 'pm_score': 2, 'selected': False, 'text': '<p>I found <a href="http://green.sourceforge.net/" rel="nofollow">Green</a> plugin very simple to use and to generate class diagram from source code.\nGive it a try :).\nJust copy the plugin to your plugin dir.</p>\n'}, {'answer_id': 8751193, 'author': 'Thomas Ahle', 'author_id': 205521, 'author_profile': 'https://Stackoverflow.com/users/205521', 'pm_score': 8, 'selected': False, 'text': '<h1><a href="http://www.objectaid.com/home" rel="noreferrer">ObjectAid UML Explorer</a></h1>\n\n<p>Is what I used. It is easily <strong><a href="https://www.objectaid.com/install-objectaid" rel="noreferrer">installed</a></strong> from the repository:</p>\n\n<pre><code>Name:     ObjectAid UML Explorer\nLocation: http://www.objectaid.com/update/current\n</code></pre>\n\n<p>And produces quite nice UML diagrams:</p>\n\n<p><img src="https://i.stack.imgur.com/QPnZD.png" alt="Screenshot"></p>\n\n<h2>Description from the website:</h2>\n\n<blockquote>\n  <p>The ObjectAid UML Explorer is different from other UML tools. It uses\n  the UML notation to show a graphical representation of existing code\n  that is as accurate and up-to-date as your text editor, while being\n  very easy to use. Several unique features make this possible:</p>\n  \n  <ul>\n  <li>Your source code and libraries are the model that is displayed, they are not reverse engineered into a different format.</li>\n  <li>If you update your code in Eclipse, your diagram is updated as well; there is no need to reverse engineer source code.</li>\n  <li>Refactoring updates your diagram as well as your source code. When you rename a field or move a class, your diagram simply reflects the\n  changes without going out of sync.</li>\n  <li>All diagrams in your Eclipse workspace are updated with refactoring changes as appropriate. If necessary, they are checked out of your\n  version control system.</li>\n  <li>Diagrams are fully integrated into the Eclipse IDE. You can drag Java classes from any other view onto the diagram, and diagram-related\n  information is shown in other views wherever applicable.</li>\n  </ul>\n</blockquote>\n'}, {'answer_id': 10966290, 'author': 'Ismail Marmoush', 'author_id': 263215, 'author_profile': 'https://Stackoverflow.com/users/263215', 'pm_score': 6, 'selected': False, 'text': '<p>EDIT:\nIf you\'re a designer then <a href="http://www.papyrusuml.org" rel="nofollow noreferrer">Papyrus</a> is your best choice it\'s very advanced and full of features, but if you just want to sketch out some UML diagrams and easy installation then <a href="http://objectaid.com/" rel="nofollow noreferrer">ObjectAid</a>  is pretty cool and it doesn\'t require any plugins I just installed it over Eclipse-Java EE  and works great !.</p>\n\n<hr>\n\n<p><strong>UPDATE Oct 11th, 2013</strong></p>\n\n<p>My original post was in June 2012 a lot of things have changed many tools has grown and others didn\'t. Since I\'m going back to do some modeling and also getting some replies to the post I decided to install papyrus again and will investigate other possible UML modeling solutions again. UML generation (with synchronization feature) is really important not to software designer but to the average developer.</p>\n\n<p>I wish papyrus had straightforward way to Reverse Engineer classes into UML class diagram and It would be super cool if that reverse engineering had a synchronization feature, but unfortunately papyrus project is full of features and I think developers there have already much at hand since also many actions you do over papyrus might not give you any response and just nothing happens but that\'s out of this question scope anyway.</p>\n\n<p><strong>The Answer</strong> (Oct 11th, 2013)</p>\n\n<p><strong>Tools</strong></p>\n\n<ol>\n<li>Download Papyrus</li>\n<li>Go to Help -> Install New Software...</li>\n<li>In the <em>Work with:</em> drop-down, select <em>--All Available Sites--</em></li>\n<li>In the filter, type in <em>Papyrus</em></li>\n<li>After installation finishes restart Eclipse</li>\n<li>Repeat steps 1-3 and this time, install <em>Modisco</em></li>\n</ol>\n\n<p><strong>Steps</strong></p>\n\n<ol>\n<li>In your java project (assume it\'s called MyProject) create a folder e.g UML</li>\n<li>Right click over the project name -> Discovery -> Discoverer -> Discover Java and inventory model from java project, a file called MyProject_kdm.xmi will be generated.\n<img src="https://i.stack.imgur.com/4PnYJ.png" alt="enter image description here"></li>\n<li>Right click project name file --> new --> papyrus model -> and call it MyProject.</li>\n<li>Move the three generated files MyProject.di , MyProject.notation, MyProject.uml to the UML folder</li>\n<li><p>Right click on MyProject_kdm.xmi -> Discovery -> Discoverer -> Discover UML model from KDM code again you\'ll get a property dialog set the serialization prop to TRUE to generate a file named MyProject.uml \n<img src="https://i.stack.imgur.com/x4YZO.png" alt="enter image description here"></p></li>\n<li><p>Move generated MyProject.uml which was generated at root, to UML folder, Eclipse will ask you If you wanted to replace it click yes. What we did in here was that we replaced an empty model with a generated one.</p></li>\n<li><p>ALT+W -> show view -> papyrus -> model explorer</p></li>\n<li><p>In that view, you\'ll find your classes like in the picture \n<img src="https://i.stack.imgur.com/VLL54.png" alt="enter image description here"></p></li>\n<li><p>In the view Right click root model -> New diagram <img src="https://i.stack.imgur.com/jIBGE.png" alt="enter image description here"></p></li>\n<li><p>Then start grabbing classes to the diagram from the view</p></li>\n</ol>\n\n<p><strong>Some features</strong></p>\n\n<ul>\n<li><p>To show the class elements (variables, functions etc) Right click on any class -> Filters -> show/hide contents  Voila !!</p></li>\n<li><p>You can have default friendly color settings from Window -> pereferences -> papyrus -> class diagram</p></li>\n<li><p>one very important setting is <strong>Arrange</strong> when you drop the classes they get a cramped right click on any empty space at a class diagram and click Arrange All</p></li>\n<li><p>Arrows in the model explorer view can be grabbed to the diagram to show generalization, realization etc</p></li>\n<li><p>After all of that your settings will show diagrams like \n<img src="https://i.stack.imgur.com/CEPI8.png" alt="enter image description here"></p></li>\n<li><p>Synchronization isn\'t available as far as I know you\'ll need to manually import any new classes.</p></li>\n</ul>\n\n<p>That\'s all, And don\'t buy commercial products unless you really need it, papyrus is actually great and sophisticated instead donate or something.</p>\n\n<p>Disclaimer: I\'ve no relation to the papyrus people, in fact, I didn\'t like papyrus at first until I did lots of research and experienced it with some patience. And will get back to this post again when I try other free tools.</p>\n'}, {'answer_id': 31780857, 'author': 'Masood', 'author_id': 2713018, 'author_profile': 'https://Stackoverflow.com/users/2713018', 'pm_score': 0, 'selected': False, 'text': '<p>I suggest PlantUML. this tools is very usefull and easy to use. PlantUML have a plugin for Netbeans that you can create UML diagram from your java code.</p>\n\n<p>you can install PlantUML plugin in the netbeans by this method:</p>\n\n<p>Netbeans Menu -> Tools -> Plugin</p>\n\n<p>Now select Available Plugins and then find PlantUML and install it.</p>\n\n<p>For more information go to website: www.plantuml.com</p>\n'}, {'answer_id': 39018106, 'author': 'juanmf', 'author_id': 711855, 'author_profile': 'https://Stackoverflow.com/users/711855', 'pm_score': 3, 'selected': False, 'text': '<p>I developed a <strong>maven plugin that can</strong> both, be run from CLI as a plugin goal, or import as dependency and programmatically use the parser, <code>@see Main#main()</code> to get the idea on how. </p>\n\n<p>It <strong>renders <a href="http://plantuml.com/classes.html" rel="nofollow noreferrer">PlantUML</a> src code of desired packages recursively</strong> that you can edit manually if needed (hopefully you won\'t). Then, by pasting the code in the plantUML page, or by downloading plant\'s jar you can render the UML diagram as a png image.  </p>\n\n<p>Check it out here <a href="https://github.com/juanmf/Java2PlantUML" rel="nofollow noreferrer">https://github.com/juanmf/Java2PlantUML</a></p>\n\n<p>Example output diagram:\n<a href="https://i.stack.imgur.com/kkUpH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kkUpH.png" alt="enter image description here"></a></p>\n\n<p>Any contribution is more than welcome. It has a set of filters that customize output but I didn\'t expose these yet in the plugin CLI params.</p>\n\n<p><strong>It\'s important to note that it\'s not limited to your *.java files, it can render UML diagrams src from you maven dependencies as well. This is very handy to understand libraries you depend on. It actually inspects compiled classes with reflection so no source needed</strong>  </p>\n\n<p>Be the 1st to star it at GitHub :P </p>\n'}, {'answer_id': 45166435, 'author': 'Ihor Rybak', 'author_id': 5810648, 'author_profile': 'https://Stackoverflow.com/users/5810648', 'pm_score': 2, 'selected': False, 'text': '<p>Using IntelliJ IDEA. To generate class diagram select package and press <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>U</kbd>:<a href="https://i.stack.imgur.com/WBXpI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WBXpI.png" alt="enter image description here"></a></p>\n\n<p>By default, it displays only class names and not all dependencies. To change it: right click -> Show Categories... and Show dependencies:\n<a href="https://i.stack.imgur.com/DFsXM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DFsXM.png" alt="enter image description here"></a></p>\n\n<p>To genarate dependencies diagram (UML Deployment diagram) and you use maven go View -> Tool Windows -> Maven Projects and press <kbd>Ctrl</kbd> + <kbd>Alt</kbd> + <kbd>U</kbd>:\n<a href="https://i.stack.imgur.com/HblBN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HblBN.png" alt="enter image description here"></a></p>\n\n<p>The result:\n<a href="https://i.stack.imgur.com/7HQhD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7HQhD.png" alt="enter image description here"></a></p>\n\n<p>Also it is possible to generate more others diagrams. See <a href="https://www.jetbrains.com/help/idea/working-with-diagrams.html" rel="nofollow noreferrer">documentation</a>.</p>\n'}, {'answer_id': 45239269, 'author': 'Devs love ZenUML', 'author_id': 529187, 'author_profile': 'https://Stackoverflow.com/users/529187', 'pm_score': 4, 'selected': False, 'text': '<blockquote>\n  <p>I am one of the authors, so the answer can be biased. It is open-source (Apache 2.0), but the plugin is not free. You don\'t have to pay (obviously) if you clone and build it locally.</p>\n</blockquote>\n\n<p>On Intellij IDEA, ZenUML can generate sequence diagram from Java code.\n<a href="https://i.stack.imgur.com/UcsWi.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UcsWi.gif" alt="enter image description here"></a></p>\n\n<p>Check it out at <a href="https://plugins.jetbrains.com/plugin/12437-zenuml-support" rel="nofollow noreferrer">https://plugins.jetbrains.com/plugin/12437-zenuml-support</a></p>\n\n<p>Source code: <a href="https://github.com/ZenUml/jetbrains-zenuml" rel="nofollow noreferrer">https://github.com/ZenUml/jetbrains-zenuml</a></p>\n'}, {'answer_id': 52669901, 'author': 'whoami - fakeFaceTrueSoul', 'author_id': 7237613, 'author_profile': 'https://Stackoverflow.com/users/7237613', 'pm_score': 1, 'selected': False, 'text': "<p>I've noticed SequenceDiagram plugin for Intellij is also a good option.</p>\n"}, {'answer_id': 57943814, 'author': 'abulka', 'author_id': 528955, 'author_profile': 'https://Stackoverflow.com/users/528955', 'pm_score': 1, 'selected': False, 'text': '<p>Another modelling tool for Java is (my) website <a href="https://www.gituml.com" rel="nofollow noreferrer">GitUML</a>.\nGenerate UML diagrams from Java or Python code stored in GitHub repositories. </p>\n\n<p>One key idea with GitUML is to address one of the problems with "documentation": that diagrams are always out of date. With GitUML, diagrams automatically update when you push code using git.</p>\n\n<p>Browse through community UML diagrams, there are some Java design patterns there. Surf through popular GitHub repositories and visualise the architectures and patterns in them.</p>\n\n<p><a href="https://i.stack.imgur.com/hjt0p.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hjt0p.png" alt="diagram browser"></a></p>\n\n<p>Create diagrams using point and click. There is no drag drop editor, just click on the classes in the repository tree that you want to visualise:</p>\n\n<p><a href="https://i.stack.imgur.com/O6ARG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/O6ARG.png" alt="select the java classes you want to visualise"></a></p>\n\n<p>The underlying technology is PlantUML based, which means you can refine your diagrams with additional PlantUML markup.</p>\n'}, {'answer_id': 60583105, 'author': 'Happy', 'author_id': 2412606, 'author_profile': 'https://Stackoverflow.com/users/2412606', 'pm_score': 1, 'selected': False, 'text': '<p>There is a <strong>Free</strong> tool named <a href="https://github.com/fuiny/binarydoc-docker" rel="nofollow noreferrer">binarydoc</a> which can generate <code>UML Sequence Diagram</code>, or <code>Control Flow Graph</code> (<code>CFG</code>) from the <code>bytecode</code> (instead of source code) of a Java method.</p>\n<p>Here is an sample diagram <strong>binarydoc</strong> generated for the java method <a href="https://openjdk.binarydoc.org/net.java/openjdk/13.0/method?classfilelocation=java.net.abstractplainsocketimpl&amp;seq=19&amp;methodname=getInputStream" rel="nofollow noreferrer">java.net.AbstractPlainSocketImpl.getInputStream</a>:</p>\n<ul>\n<li><strong>Control Flow Graph</strong> of method <code>java.net.AbstractPlainSocketImpl.getInputStream</code>:</li>\n</ul>\n<p><a href="https://i.stack.imgur.com/xuV2z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xuV2z.png" alt="Control Flow Graph" /></a></p>\n<ul>\n<li><strong>UML Sequence Diagram</strong> of method <code>java.net.AbstractPlainSocketImpl.getInputStream</code>:</li>\n</ul>\n<p><a href="https://i.stack.imgur.com/fQ3HW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fQ3HW.png" alt="UML Sequence Diagram" /></a></p>\n'}]
['https://Stackoverflow.com/questions/51786', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1772/']