How To Create Your Own Stand-alone EMF Application
Most of our use in EMF is for RCP (Rich Client Platform) applications. in that case the EMF model is implemented as a plug-in app. We encountered the need for a stand-alone EMF app, as part of an integration build operation. Finally Oron Mark and I managed to create this stand-alone .jar app, that exploits EMF abilities.
- From Eclipse IDE go to Help →Install New Software:
- In case you’re using Eclipse Oxygen you can use this URL.
- From Modeling you need to install: XSD - XML Schema Definition SDK and EMF - Eclipse Modeling Framework SDK.
Start a new EMF project
From Eclipse’s new project wizard, go to Eclipse Modeling Framework and choose EMF Project.
Enter your project name, choose XML Schema, and enter you’re .xsd root file. In our case we use the IPXACT 1685–2014 format,you can get the .xsd here, and use the index.xsd as the Model’s root.
Click Next and choose the Root package to load from.
From the project that has been created, in the model folder, double-click the index.genmodel, then right-click on the root icon (index in our case), and choose Generate all:
Once the generation is complete your project should look similar to this:
Loading your xml based data and instantiate the model
For the instantiation you’ll need to register you’re factory and package. we propose the following:
Since this is a stand-alone application it needs a main function that initiates the flow. We propose the following:
Exporting your app to a .jar file
From File → Export, choose Java → Runnable JAR file
Choose Launch Configuration, enter Export Destination and from Library Handling choose the Package required libraries into generated JAR option
You can run this by using
c:\MyData>java -jar myStandAloneApp.jar from command line.