Skip to content

Running Epsilon from Java

While Epsilon's development tools are based on Eclipse, its runtime is not, and can be used from any (headless) Java application. For example, the back-end of the Epsilon Playground is a headless, server-less Java application that runs on Google's Cloud Platform.

Did you know that ...

Contrary to popular belief, EMF is not tightly coupled to the Eclipse IDE either, and can also be embedded in any Java application by importing a couple of dependencies from MavenCentral.


Epsilon libraries are available on MavenCentral. Below is a fragment of a Maven pom.xml file, where we declare dependencies to the execution engine of Epsilon's core expression language and on Epsilon's driver for EMF-based models. As the EMF driver has a dependency on EMF, we don't need to declare a dependency to the EMF libraries on MavenCentral; Maven will fetch these automatically for us.


Parsing and Executing Epsilon Programs

Having declared a dependency to the EOL engine, parsing and executing an EOL program is as simple as that.

EolModule module = new EolModule();
module.parse(new File("program.eol"));


By replacing EolModule with EtlModule, EvlModule etc. you can parse and execute ETL transformations, EVL validation constraints etc. EGL deviates from this pattern and if you wish to execute a single template you should use the EglTemplateFactoryModuleAdapter class.

Loading Models

Most of your Epsilon programs will need to run against models of some sort. To run an EOL program against a model (model.xmi) that conforms to a file-based Ecore metamodel (metamodel.ecore), you can extend the code above as follows.

// Loads the EMF model
EmfModel model = new EmfModel();

// Parses and executes the EOL program
EolModule module = new EolModule();
module.parse(new File("program.eol"));
// Makes the model accessible from the program

// Saves any changes to the model
// and unloads it from memory

Analysing Epsilon Programs

As of version 2.3, Epsilon programs can be analysed using visitors. As an example, see the EolUnparser class which recursively visits the contents of an EolModule and pretty-prints it. To implement your own analyser, you will need to implement the IEolVisitor interface for EOL, or the respective IE*lVisitor interfaces for other Epsilon-based languages. Using a combination of E*lUnparser and your custom visitor, you can easily rewrite Epsilon programs too.

EolModule module = new EolModule();
module.parse("'Hello world'.println();");

EolUnparser unparser = new EolUnparser();
// Prints "Hello world".println();

More Examples

In Epsilon's Git repository, there are two example projects that show how to run Epsilon from Java, and the ANT Epsilon tasks in a headless environment (i.e. from command line).