Reverse Engineering Sequence Diagram from Java Source Code

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 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.

November 10, 2014
User Rating: / 37
Views: 60,134
PDF Link Add comments
Edition: Standard or above (Edition comparison)

  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. Start Visual Paradigm
  4. Create a new project by selecting Project > New from the toolbar. In the New Project window, name the project as Account Registration and click Create Blank Project button.
    new project
  5. Select Tools > Code > Instant Reverse Java to Sequence Diagram... from the toolbar.
  6. In the Instant Reverse Java to Sequence Diagram window, click on Add Source Folder... button.
  7. Select the extracted source folder src. Click Next button.
  8. Select the method to visualize. Select src > RegisterController.java > register (String,int). Click the Next button.
    03 instant reverse java to sequence diagram
  9. 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
  10. As a result, a 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).

Related Links

  1. Instant reverse Java sources to sequence diagram

Resources

  1. Sample.zip

Rate this Article

Click on one of the stars below to rate this article from 1 (lowest) to 5 (highest).

You may be interested in

  1. Data Flow Diagram (DFD) Tutorial
  2. Writing Effective Use Case
  3. Share Design, Discuss Design with PostMania
    Tagged:
  4. Draw Entity Relationship Diagram (ERD)
    Tagged:
  5. Perform UML Modeling in NetBeans
Tags of this article:

Comments (21)

written by Carlos on May 9, 2014

Not working, it does not display the operations to select. I use 11.1

written by Jick Yeung (VP) on May 12, 2014

Hi Carlos,

Thank you for your post. Would you mind submitting a ticket to us, so that we can perform a detailed checking with you? You can submit a ticket at:
http://www.visual-paradigm.com/support/

If possible, please submit your source code. If not, please provide us with some screenshots regarding your selecting in the various screens that prompted during the reverse engineering process.

Look forward to hearing from you.

written by Ewout Van Gossum on May 17, 2014

I'm using an academic license of 10.2, and I'm having the same problem as Carlos. I submitted a ticket with a screenshot here:
https://support.visual-paradigm.com/index.php?/Tickets/Ticket/View/WSO-936-96958

written by mr_problem on August 2, 2014

having the same problem as carlos

written by D. Singh on August 6, 2014

I have same issue. It does not show operations/functions to select from java class which seems like a very basic functionality.

written by Jick Yeung (VP) on August 8, 2014

Hi mr_problem and D. Singh,

Please make sure you have properly selected the root folder of source files. If you are sure you have made it right, please submit a ticket by attaching a screenshot of your folder structure, and your folder selection in the Reverse window. You can submit a ticket at:
http://www.visual-paradigm.com/support/

written by Sandy on December 23, 2014

I'am also having this isssue. The "+" sign next to the source file is not displayed.

written by Sourena on January 8, 2015

This feature does not work!

written by Jick Yeung on January 15, 2015

Hi Sourena,

We are sorry to know about this. Could you tell us more about the problem? What did you do and did you see any warning/message message?

written by Sourena on January 15, 2015

No, just like some other people said already, on the select operation dialog the plus icon never showed up and therefore I could not select any java files to generate the graph from.

written by Sourena on January 15, 2015

I have an idea why this may be the case, the code I was trying to generate a sequence diagram from was both threaded and annotated which means it was calling a service method from its run() method which in turn invoked the service by passing the ClassX.class reference to a generic getService() method and then once that was resolved then the actual method was called so I though the sequence diagram generator code may not be smart enough to recognize this case since it's not a straightforward function call like: ClassXInstance.Method1(param1). Hope this helps since I cannot share actual code!

written by James Hamilton on January 23, 2015

Having the same problem: no plus sign to select an action with. In my case I am using the ConstantContact API, which is available from GitHub: https://github.com/constantcontact/java-sdk

Trying to reverse a sequence diagram from the ConstantContact class

written by Jick Yeung (VP) on January 23, 2015

Thanks everyone. I have forwarded all your feedback to our team to study. When there is any finding I will post here.

written by Jick Yeung (VP) on January 23, 2015

Thanks everyone. I have forwarded all your feedback to our team to study. When there is any finding I will post here.

written by Jick Yeung (VP) on January 23, 2015

Hi James,

The problem could be caused by file encoding. How did you get the file? Did you get that from GIT, or by copying the code and pasting it to a file, saving it manually in the text editor?

written by James Hamilton on January 23, 2015

I got it from git

written by Jick Yeung (VP) on January 23, 2015

Is your GIT set to use default system encoding? We found that default system encoding is needed.

written by Sourena on January 24, 2015

Encoding should not be an issue because other diagrams such as class diagrams and package diagrams are generated without any issues, why is it an issue with the sequence diagram?

written by Jick Yeung (VP) on January 26, 2015

Hi Sourena and James,

Could you send us your log file for checking? You can export it from the About window (Help > About Visual Paradigm...). And James, if possible could you send us the file "ConstantContact" for checking?

You can send us the file by submitting a ticket at:
http://www.visual-paradigm.com/support/

written by subhashish on February 24, 2015

Is there a way to ignore certain package stems (e.g. java.util) or only include certain package stems (e.g com.mycompany) while reverse engineering to generate sequence diagram?
I got VP to generate a pretty nice diagram but would want to remove calls to 3rd party framework and java classes.

written by Subhashish on February 24, 2015

Found an option via "Diagram content" --> "Show/Hide" ---> "Show/Hide diagram elements". That'll do as a workaround.

Write comment

Rating

Comment

Enter the calculation result

security code