Creating The Reverse
Creating The Reverse
category to NetBeans, with three project templates. Platform-Independent Model projects use standard
UML notation for class attributes and operations, and do no code generation. This template is useful in
the initial stages of the development process, when all models are “conceptual” and not “physical”.
Java-Platform Model projects use Java syntax for class attributes and operations and must be linked to a
Java Application or Library project. NetBeans will keep both projects in sync: If you edit the code, the
UML model will change to reflect new or changed classes, attributes and operations, and if you change
the UML model, the source code will be modified accordingly. We’ll use the third project template,
which populates a Java-Platform Model from an existing Java project. Click the New Project icon and
choose the UML category. Then select Java-Platform Model by Reverse Engineering a Java Project.
Accept the defaults for the next step, except for selecting the Todo Java project; then click Finish.
NetBeans will scan the sources and populate the project with model elements for Java packages, classes
and interfaces. (Note that for large projects this may take a long time and eat up a large amount of
memory.) If you experience OutOfMemory errors while reverse engineering, you can edit the file
etc/netbeans.conf inside your NetBeans installation and change the value for –Xmx, increasing the
maximum heap size from 128M to 256M or bigger. While scanning, the IDE shows a log window
detailing the progress for each source file. Exploring the reverse-engineered model Expand the Model
container and you’ll see that it includes both application-specific and standard Java packages and
classes. As a UML model cannot reference anything it does not contain or import, NetBeans creates
model elements for Java SE classes. (An alternative would be having a UML model with the Java SE API
and import elements from it.) Sometimes NetBeans will create duplicates, like the many List elements
you see. It’s better to leave them as they are, as removing them may delete attributes from the Java
project.