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

10 Comments

  1. adjiee July 26, 2007
  2. linglom July 29, 2007
  3. Vanessa March 19, 2009
  4. Joe L. May 5, 2009
  5. Joyce C March 18, 2011
  6. krunal patel May 2, 2011
  7. Darragh May 6, 2011
  8. unnati January 4, 2013
  9. gamini January 21, 2014
  10. Sean April 13, 2016

Leave a Reply