UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code

This entry is part 4 of 4 in the series UML Modeling on NetBeans 5.5

UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code

Now I will show about how to generate a diagram from an existing code. It also can be called reverse engineering method. This example I will generate a class diagram from my existing source codes.

  1. Create a new Project. File -> New Project
    On left side, Category, select UML.
    On right side, Projects, select Reverse Engineer a Java Project. Then click Next.
  2. New Reverse Engineer a Java Project

  3. Project Name, type ‘UMLDemo’ or any name you want.
    On the middle, you’ll see Java Project, select the project that contain existing source code that you want to create a diagram. Then move down a bit, ensure the check box has been checked on the folder that contain the source code.
    In this example, I select Dicomu project and check only src folder which contain my source code.
  4. Select source code project
  5. When the project has created, try expand Model -> your source project name on the Projects window. You’ll see the files from your source project has been created here as in the figure below.
  6. Project created
  7. Select the file names that you want to create a diagram by highlight them (hold shift + select first and last file). I select almost all files from my source project except TestDicom.
  8. Select files for reverse engineering
  9. Then right click on the highlight files, select Create Diagram From Selected Elements…
  10. Create a diagram
  11. In Diagram type, select Class Diagram and Name as DicomuClassDiagram.
    The namespace leave it as the same. Click Finish.
  12. Select diagram type
  13. The class diagram will be generated as the figure below. Notice that the relation also been created from the source code automatically. For how to export a diagram to image can be found at the bottom in Part II.
  14. A generated Class diagram

That’s all. Complete all 4 parts. I think these series of tutorial can help you understanding and using UML Modeling on NetBeans better.

Series Navigation<< UML Modeling on NetBeans, Part 3: Generate code from UML Diagram

9 Responses to “UML Modeling on NetBeans, Part 4: Generate UML Diagram from Code”

  1. linglom

    You can save the tutorial from your browser by yourself for reading when off-line. For example; Internet Explorer, click File -> Save As.. –> select type as Web archive, single file.

  2. Darragh

    Hi,
    followed the steps above but the UML didn’t populate with source from my project.using NB6.8
    Any ideas

Comments are now closed for this article. If you still have issue and would like to discuss, you can post in the forum or send me a message.