Creating your first Eclipse e4 Application

Eclipse released on the 29 July 2009 the tech preview version 0.9 of Eclipse e4, which can be downloaded here.

I wasn’t able to find a description how to create an new application based on E4. Starting from the CVS example is possible but I wanted to start from scratch. After several failed attempts to create an E4 application I believe I have found a way to create an E4 application. I assume others will have similar problems so I wanted to share my experience.

To follow this description you need to have knowledge how to develop Eclipse Plugins in Eclipse 3.5 or earlier. Check out this Eclipse Plugin Development Tutorial.

So lets get started with e4.

Download e4. Extract it and start it is similar to older Eclipse versions.

Currently there is no wizard which creates a working scaffold of an E4 application. We will therefore use the exsting plugin templates.

Create a new Plugin project “de.vogella.e4.first”. Do not select “Generate an activator”, nor “This plug-in will make contributions to the UI” nor “Would you like to create a rich client application”. Do not select a template. Press finish.


This will open the Plugin Perspective, switch here to the Package Explorer to see your new project.

Create the package “de.vogella.e4.first”. The result should look like the following.


Select your MANIFEST.MF and add the following dependencies to your plugin.

01 Manifest-Version: 1.0
02 Bundle-ManifestVersion: 2
03 Bundle-Name: First
04 Bundle-SymbolicName: de.vogella.e4.first;singleton:=true
05 Bundle-Version: 1.0.0.qualifier
06 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
07 Require-Bundle: org.eclipse.ui,
08 org.eclipse.core.runtime,
09 org.eclipse.e4.ui.workbench;bundle-version="0.9.0",
10 org.eclipse.e4.ui.workbench.renderers.swt;bundle-version="0.9.0",
11 org.eclipse.e4.ui.workbench.renderers.swt.contributions;bundle-version="0.9.0",
12 org.eclipse.e4.ui.workbench.swt;bundle-version="0.9.0",

You need (some of) these plugins for the usage of E4 features.

Add the following extension points. I noticed that for some of the features you have to modify the plugin.xml directly as the UI does not support them. But you have to create the plugin.xml via the MANIFEST.MF file; as I created it directly as a new file I received a strange system behavior.

01 <?xml version="1.0" encoding="UTF-8"?>
02 <?eclipse version="3.4"?>
03 <plugin>
04 <extension
05 point="">
06 <part
07 class="de.vogella.e4.first.views.View1"
08 label="My first E4 View"
09 parentId="org.eclipse.e4.ui.tags.navigation">
10 </part>
11 </extension>
12 <extension
13 id="product"
14 point="org.eclipse.core.runtime.products">
15 <product
16 application="org.eclipse.e4.ui.workbench.swt.application"
17 name="vogella">
18 <property
19 name="appName"
20 value="vogella">
21 </property>
22 <property
23 name="applicationXMI"
24 value="de.vogella.e4.first/Application.xmi">
25 </property>
26 </product>
28 </extension>
30 </plugin>

“” is a new extension point by which you can define your view parts, formally known as views and editors.

The extension point “org.eclipse.core.runtime.products” has a new parameter “applicationXMI”. This is a parameter to the model of your UI. We came to this later. You also do not define your own application; we use “org.eclipse.e4.ui.workbench.swt.application”.

Create a product configuration called “vogella.product”. This is similar to Eclipse 3.5; see here for a description: Eclipse Product Configuration.


Make sure you select “org.eclipse.e4.ui.workbench.swt.application”.


Add as dependency to your product the plugin “org.eclipse.e4.ui.workbench”. Add also the plugin “de.vogella.e4.first”.
Press “add required plugins”.

Create the following two classes:

1 package de.vogella.e4.first.handlers;
3 import org.eclipse.e4.workbench.ui.IWorkbench;
5 public class ExitHandler {
6 public void execute(IWorkbench workbench) {
7 workbench.close();
8 }
9 }


01 package de.vogella.e4.first.views;
03 import;
04 import org.eclipse.jface.layout.GridLayoutFactory;
05 import org.eclipse.swt.SWT;
06 import org.eclipse.swt.layout.GridData;
07 import org.eclipse.swt.widgets.Composite;
08 import org.eclipse.swt.widgets.Label;
09 import org.eclipse.swt.widgets.Text;
10 import;
12 public class View1 implements IDisposable {
14 public View1(Composite parent, final IEclipseContext outputContext) {
15 Label label = new Label(parent, SWT.NONE);
16 label.setText("E4 is new");
17 GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
18 gridData.horizontalIndent = 20;
19 label.setLayoutData(gridData);
20 Text text = new Text(parent, SWT.NONE);
21 text.setText("and different");
22 GridLayoutFactory.fillDefaults().generateLayout(parent);
23 }
25 public void dispose() {
27 }
28 }

You need a model for your application. In the parameter “applicationXMI” we earlier defined that this model will be “de.vogella.e4.first/Application.xmi”. Create the file Application.xmi with the following content.

01 <?xml version="1.0" encoding="ASCII"?>
02 <application:MApplication xmi:version="2.0" xmlns:xmi="" xmlns:xsi="" xmlns:application="">
03 <windows name="Main" x="100" y="100" width="800" height="600">
04 <menu>
05 <items xsi:type="application:MMenuItem" name="File">
06 <menu>
07 <items xsi:type="application:MMenuItem" id="" name="Exit" command="//@command.0"/>
08 </menu>
09 </items>
10 </menu>
11 <children policy="VerticalComposite">
12 <children xsi:type="application:MSashForm" policy="HorizontalSash">
13 <children xsi:type="application:MStack">
14 <children xsi:type="application:MContributedPart" iconURI="" name="My View" tooltip="My first View" URI="platform:/plugin/de.vogella.e4.first/de.vogella.e4.first.views.View1"/>
15 </children>
16 <weights>30</weights>
17 <weights>70</weights>
18 </children>
19 </children>
20 <handlers id="" URI="platform:/plugin/de.vogella.e4.first/de.vogella.e4.first.handlers.ExitHandler" persistedState="" command="//@command.0"/>
21 </windows>
22 <command id="application.exit" name="Exit"/>
23 </application:MApplication>

This is the EMF model which defines your UI. Eclipse should display this model in a EMF editor so that you can investigate it. In this model you find your view and command definition. The content can be viewed via the properities view.


Now start your application from your vogella.product. Starting it directly from the plugin.xml will not work (easily).

If you receive the error “org.eclipse.core.runtime.AssertionFailedException: null argument:-applicationXMI argument missing” check you plugin.xml. E4 created in several cases twice the products entry.

You should be rewarded ;-) with this user interface:


With this first application I hope you can started using the E4 advanced features, e.g. CSS styling, etc.

My final thoughts: Eclipse e4 has already amazing capabilities for a tech review release. The new modeled UI removes the need for a lot of boilerplate code.

More Information


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s