Skip to main content

Notice: This Wiki is now read only and edits are no longer possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

EMF/FAQ (Archived)

< EMF(Redirected from EMF-FAQ (Archived))

This page contains archived (old) FAQ entries which are no longer relevant to the current EMF version.

For the latest, see EMF FAQ.


I want to use EMF, SDO, or XSD 2.1 in my standalone project, or include only a working subset of the code. What libraries (jar files) do I need in my CLASSPATH?

Eclipse Modeling Framework (EMF) provides the infrastructure to run the generated models and dynamic model based on existing ecore files. It also provides XMI/XML serialization and deserialization.

The following jars can be used in standalone mode. Jars are found under the plugins directory of your Eclipse installation - there will be a release number appended to the plugin name, e.g. org.eclipse.emf.common_2.1.0.

Add to the following jars to your CLASSPATH or copy them into your project. This includes, but is not limited to:

  • org.eclipse.emf.common/runtime/common.jar
  • org.eclipse.emf.common/runtime/common.resources.jar (needed at runtime, not at compile time)
  • org.eclipse.emf.ecore/runtime/ecore.jar
  • org.eclipse.emf.ecore/runtime/ecore.resources.jar (needed at runtime, not at compile time)
  • org.eclipse.emf.ecore.change/runtime/ecore.change.jar
  • org.eclipse.emf.ecore.xmi/runtime/ecore.xmi.jar (requires SAX parser - see note below)

Service Data Objects (SDO) is an API specification in the format of Java interfaces and the EMF implementation that requires the EMF jars above and the following jars to be used in standalone mode:

  • org.eclipse.emf.commonj.sdo/runtime/commonj.sdo.jar
  • org.eclipse.emf.ecore.sdo/runtime/ecore.sdo.jar

XML Schema Infoset Model (XSD) is a reference library for use with any code that manipulates XML schemas and requires the EMF jars above and the following jars to be used in standalone mode:

  • org.eclipse.xsd/runtime/xsd.jar
  • org.eclipse.xsd/runtime/xsd.resources.jar (needed at runtime, not at compile time)
  • org.eclipse.xsd.test/runtime/xsd.test.jar

NOTE: If using ecore.xmi or any of the XSD jars, you will require a SAX parser such as Xerces.

For more information on working outside Eclipse, see the question "How do I use EMF in standalone applications (such as an ordinary main)?".

How do I use EMF 2.1 in standalone applications (such as an ordinary main)?

An EMF model can be used without change in a standalone application with couple of exceptions.

Default resource factories are not registered in the standalone EMF environment. Therefore, for each file extension or scheme your application wants to load or save, you need to register the corresponding resource factory. For example, to load and save XMI documents, add a line similar to the one below to your main program:

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("library", new XMIResourceFactoryImpl());

To load and save XML documents, register the following factory:

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());

In the above examples, the model is registered using the global static resource factory registry instance. You can also register factories local to the ResourceSet being used, e.g:

ResourceSet rs = new ResourceSet();
rs.getResourceFactoryRegistry().getExtensionToFactoryMap().put(("xml", new XMLResourceFactoryImpl());

In addition, you'll also need to register your package, which happens as a side effect of accessing XyzPackage.eINSTANCE. For example, to register the library model, add the following line to your main program:

LibraryPackage packageInstance = LibraryPackage.eINSTANCE;

You need to add to the CLASSPATH all the jars for the plugins (and their dependent plugins) that you want to use standalone. The list is dependent on exactly what plugins you want to use and is available by looking at the runtime libraries in their plugin.xml files. This includes, but is not limited to:

  • org.eclipse.emf.common/runtime/common.jar
  • org.eclipse.emf.common/runtime/common.resources.jar
  • org.eclipse.emf.ecore/runtime/ecore.jar
  • org.eclipse.emf.ecore/runtime/ecore.resources.jar
  • org.eclipse.emf.ecore.xmi/runtime/ecore.xmi.jar

The jars are found under the plugins directory of your Eclipse installation. There will be a release number appended to the plugin name, e.g. org.eclipse.emf.common_2.1.0.

For EMF.Edit you would also have to add the following jar files to your classpath:

  • org.eclipse.emf.common.ui/runtime/common.ui.jar
  • org.eclipse.emf.common.ui/runtime/common.ui.resources.jar
  • org.eclipse.emf.edit/runtime/edit.jar
  • org.eclipse.emf.edit/runtime/edit.resources.jar


Also, to produce the right .jar file for standalone execution of a generated project, you need to copy the plugin.properties file and the icons directory to the directory containing the EMF XyzPlugin for the project. This will put the resources in just the right place to be found by the generated XyzPlugin during standalone execution. Such a project will work as both a plugin and for standalone execution.

Back to the top