Skip to main content
Jump to: navigation, search

MDT/UML2/Getting Started with UML2

< MDT‎ | UML2
Revision as of 23:00, 11 October 2011 by (Talk | contribs)

Copyright © 2004, 2011 International Business Machines Corp. and CEA


This article describes how to get started with the UML2 plug-ins for Eclipse. In particular, it gives an overview of how to create models (and their contents) both programmatically and by using the sample UML editor.

Kenn Hussey and James Bruck Last Updated: October 12, 2011


To start using UML2 (and to follow along with the example in this article), you must have Eclipse, EMF, and UML2 installed. You can either download the Modeling Tools Package or follow these steps:

  1. Download and run Eclipse.
  2. Select the Help > Install New Software… menu item.
  3. Select a software site to work with, e.g., Indigo -
  4. Expand the Modeling tree item.
  5. Select UML2 Extender SDK and press the Next > button.
  6. Review the install details and press the Next > button.
  7. Accept the terms of the license agreement and press the Finish button.
  8. Restart Eclipse when prompted to do so.

GSWU2 Prerequisites.png

At this stage, UML2 and all dependencies should be installed.


This article will walk you through the basics of creating models using UML2. Using a simple model (the ExtendedPO2 model, shamelessly “borrowed” from the EMF “bible” [1]) as an example, we’ll look at what’s involved in creating some of the more common elements that make up a model. For each type of element, we’ll first explain the creation process using the sample UML editor and then explore how to accomplish the same thing using Java code. The ExtendedPO2 model is shown below.

GSWU2 Introduction.gif

Getting Started

Before getting started, you’ll need to create a simple project in your workspace. This project will serve as the container for the model that we’ll create using the UML editor. To create a simple project for this article, follow these steps:

  1. Select the Window > Open Perspective > Other… menu item.
  2. Select the Resource perspective and press the OK button.
  3. Select the File > New > Project... menu item.
  4. Select the Project wizard from the General category and press the Next > button.
  5. Enter a project name (i.e. “Getting Started with UML2”) and press the Finish button.

At this point your workspace should look something like this:

GSWU2 GettingStarted.png

OK, that should be enough to get us going with the UML editor. Now, to follow along with the programmatic approach to creating models, we’ll assume that you’ve created a class (named, say, “GettingStartedWithUML2”) in which you can write some code to construct our sample model. The code snippets we’ll show assume you’ve defined the following utility methods to give the user information on the program’s status:

     public static boolean DEBUG = true;

     protected static void out(String output) {

            if (DEBUG) {

     protected static void err(String error) {

A static debug flag can be used to enable or disable verbose information printed to the system’s output stream. Errors will always be printed to the system’s error stream.

All righty then! In each of the following subsections, we’ll look at how to create a different kind of UML element, starting with models.

Back to the top