Support free tutorials:

vogella training Training Books

UML with Eclipse - Tutorial

Lars Vogel

Version 1.1


Revision History
Revision 0.1 - 0.3 017.12.2007 Lars
Revision 0.4 - 1.1 09.10.2008 Lars
bug fixes and enhancements

UML with Eclipse and the UM2Tools

This article gives a short overview of UML2 and explains the usage of the Eclipse UML2 Tools for modeling UML 2 diagrams.

This article is based on Eclipse 3.5.

Table of Contents

1. UML
1.1. Overview
1.2. Definition
1.3. UML Profiles
2. Installation of Eclipse UML2 Tools
3. Eclipse UML2 Tools
3.1. Creating UML Diagrams
3.2. Multiplicity
3.3. Interfaces
3.4. Viewing the .uml file
4. Appendix: Class diagrams
4.1. Overview
4.2. Classes
4.3. Attributes
4.4. Interfaces
4.5. Relationships
4.6. Export your class diagram as image
5. Appendix: Model-Driven Architecture (MDA)
5.1. Overview
5.2. Platform Independent Model (PIM)
5.3. Platform Specific Model (PSM)
5.4. Code Mode
6. Support free vogella tutorials
6.1. Thank you
6.2. Questions and Discussion
7. Links and Literature

1. UML

1.1. Overview

Eclipse supports the creation of UML2 diagrams via UML2 Tools project. UML2 Tools is a set of GMF-based editors for viewing and editing UML models.

1.2. Definition

The Unified Modeling Language (UML) is a visual language for capturing software designs and patterns. The first version of UML was defined 1994 and released by the Object Management Group (OMG) in 1997 as UML v.1.1. The syntax and a semantic of UML is defined by the OMG.

The basic building block for UML is a diagram. UML divides diagrams into structural diagrams and behavioral diagrams

The latest version UML 2 has the target to add the ability for modelers to capture more system behavior. UML 2 has the target to support model driving architectures (MDA). MDA has the target to create automatically a software program from several models.

1.3. UML Profiles

UML is intended to be extended. The formal way to extending a UML model is via a UML profile. A UML profile a collection of UML stereotypes and constraints on elements that map the generic UML to a specific problem domain or implementation. For example a UML profile can be used to support the modeling of J2EE software components.

2. Installation of Eclipse UML2 Tools

Install the following plug-in

  • UML2 Tools SDK

The UML2 Tools can be found under "Modeling" in the update manager.

Install the plugins via the update manager of eclipse (please see Using the update manager of Eclipse for details).

3. Eclipse UML2 Tools

3.1. Creating UML Diagrams

The following example will create a class diagram with the UML2 tools.

Create a new java project "de.vogella.uml2.first" and a new folder "uml2". Right-click on the folder "uml2", select New-> Other. Select UML 2.1 Diagrams and then the "class diagram" as the type.

In my example I will create a class diagram.

Define the name of you diagram as "myclasses.umlclass".

Press finish.

From the "Palette" you can now select the type of element you would like to create. For example Select "Class" and click in the whitespace to create the UML representation of a class.

The result should look like the following.

The properties view allow you to change the attributes of the elements. To open the properties view select a class, right-click and select "Show Properties View". You can then for example set the "Is Abstract" flag to true to create a abstract class.

If you select your element a menu will be displayed which allows you to add property (fields) and operations (methods).

If you select your UML diagram and click on the outgoing arrow you can create associations.


You can edit the properties and the operations names directly in the diagram. According to the UML specification the name of an operation should be followed by round brackets, e.g. you can type foo() but not foo for a operation.

Save your UML diagram.


Note that your UML diagram updates the *.uml file. In case you deleted your diagram you can re-create the diagram from the .uml file, via the right-click and by selecting the "Initialize * class diagram" entry in the menu.

3.2. Multiplicity

You can maintain the relationship multiplicity between two classes by clicking on the association and via the properties lower / upper in the property view.

3.3. Interfaces

UML2 Tool let you choose if you want to use the ball-and-socket notation (interface is displayed as a circle) or UML stereotype <<interface>> for the representation of an interface. Simple right-click on the interface and select "Show as class" of "Collapse to circle".

3.4. Viewing the .uml file

Investigate the *.uml file. The *.uml file is EMF based. Eclipse UML provides an editor for it. Alternative you can view the file directly in a text editor.

4. Appendix: Class diagrams

4.1. Overview

A class diagram captures the static relationships of your software.

4.2. Classes

A class is represented by a retangular box divided into compartments. A Compartment is an area in the box to write information. The first compartment holds the name, the second holds the attributes and the third is used for the operations.

Any compartment can be hidden to improve readability of the diagram.

UML suggests that a class name:

  • Starts with a capital letter

  • is centered in the top compartment

  • is written in a boldface font

  • is written in italics if the class is abstract

4.3. Attributes

Attributes specifies details of a class and can be simple types or objects.

Attributes can be defined inlined (as part second compartment of the diagram of the class) or as relationship.

4.3.1. Inlined Attributes

Inlined attributes are placed in the second compartment of the class. The notation for inline attribute is:

visibility name: type {multiplicity} {=default}

Table 1. 

Element Values Description





public Attribute

private Attribute

protected Attribute

package Attribute

name myName Name of the attribute following the camelCase notation
type   Class name, interface or primitive types, e.g. int
multiplicity   Optional, if not specified then it is assumed to be 1, * for any value, 1,..,* for ranges.
default   Optional, default value of the attribute

4.3.2. Attributes by Relationship

To model attributes by relationship you use an association relationship between the class which represents the attribute and the class containing the attribute.

4.3.3. Static Attributes

Static attributes (attributes that are part of the class and not part of the instance of the class) are displayed via underlining the name of the relationship.

4.4. Interfaces

Interfaces are indicated via the stereotype <<interface>> .

Relationships can be expressed via the ball-and-socket notation.

4.5. Relationships

UML defines several ways of representing relationships between classes.

4.5.1. Association

Read as "..has a.." association between classes. Drawn as a straight line between the two classes. Does not mean that the classes are owned by one, other classes may use the connected class too.

4.5.2. Aggregation

Read as "..owns a ..". Not as strong as a composite.

4.5.3. Composition

Strong relationship between classes to the point of containment. Read as " part of..". If the owning instance is destroyed then normally (not necessarily) the linked object is destroyed too.

4.5.4. Generalisation

Read as ".. is a..". Use to express inheritance. Represented by a solid line and a hollow triangular arrow. For example the following code could be expressed with the following diagram.

package animals;

public abstract class Animal {


package animals;

public class Frog extends Animal {


4.6. Export your class diagram as image

To export your diagram as image / graphic, right-click on your diagram and select File -> Save as Image File.

5. Appendix: Model-Driven Architecture (MDA)

5.1. Overview

MDA is the approach in which models are automatically translated into complete, deployable, running applications.

MDA defines several levels for these models, Platform independent models, platform specific models and code models.

5.2. Platform Independent Model (PIM)

Represents the business model to be implemented and can be described via UML. The PIM describes the processes of the business model and the structure of the system. The PIM does not specific operating system, programming language and hardware.

5.3. Platform Specific Model (PSM)

The PSM is responsible to specify the technical details to implement the PIM, e.g. the operating system, the programming language. In case several realizations / implementations for a PIM are possible then several PSM are formulated.

5.4. Code Mode

Represents the deployable code. In an ideal MDA scenario this code could be directly compiled and deployed without human interaction.

6. Support free vogella tutorials

Maintaining high quality free online tutorials is a lot of work. Please support free tutorials by donating or by reporting typos and factual errors.

6.1. Thank you

Please consider a contribution if this article helped you.

Flattr this

6.2. Questions and Discussion

If you find errors in this tutorial, please notify me (see the top of the page). Please note that due to the high volume of feedback I receive, I cannot answer questions to your implementation. Ensure you have read the vogella FAQ as I don't respond to questions already answered there.

7. Links and Literature Home of the standard body for UML Wiki about the UML2 Tool project Eclipse Modeling Project