Jump to Menu

How to Generate Sequence Diagram from Java?

Since source code is in text form, it is complex and is hard for human to read or analyze, especially when the logic is complicated and involves a large number of classes. "A picture is worth a thousand words", by visualizing source code with diagram, you can easily realize the classes involve as well as their relationship in run time. In order to help you with that, Visual Paradigm enables you to reverse your Java source code into UML sequence diagram, so that you can gain a better understanding of Java source code by reading diagram instead of looking to a possibly thousand lines of source code. This is very beneficial for both analysis and communication.

Compatible edition(s): Enterprise, Professional, Standard

  • November 10, 2014
  • Views: 249,302
  • PDF

  1. Download Sample.zip of this tutorial and extract the zip file to any directory.
  2. Study the source code. Read the register method in RegisterController.java to see how it works.
    01 java source code
  3. Create a new project by selecting Project > New from the application toolbar. In the New Project window, enter Account Registration as project name and click Create Blank Project.
    new project
  4. Select Tools > Code > Instant Reverse Java to Sequence Diagram... from the toolbar.
  5. In the Instant Reverse Java to Sequence Diagram window, click on Add Source Folder... button.
  6. Select the extracted source folder src. Click Next button.
  7. Select the method to visualize. Select src > RegisterController.java > register (String,int). Click the Next button.
    03 instant reverse java to sequence diagram
  8. You need to select a diagram to visualize the interaction. The Create new sequence diagram option is selected and diagram name is entered by default. Click Finish button.
    04 create new sequence diagram
  9. As a result, a UML sequence diagram is formed. Let's study the diagram.
    sequence diagram formed
    When a person invokes RegisterController's register method (message: 1), it creates an account object (message: 1.1). After that, the controller sets the id, name and age to the account object (message 1.2, 1.3, 1.4) and adds itself to the account list (message: 1.5). The invocation ends with a return (message 1.6).



Turn every software project into a successful one.

We use cookies to offer you a better experience. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.

OK