Running an MDWorkbench Java application

Once you deployed the launch configuration as a JAR file, you can execute it from a Java program using MDWorkbench APIs.

Setting the Java classpath

To use MDWorkbench APIs in a Java program, the classpath must include the following jars:

  1. EMF jars:

  2. MDWorkbench core engine and third-party jars:

  3. Metamodels and connector jars:

These jars are located in the folder <MDWorkbench directory>\eclipse\plugins.

Creating a Java class to execute a launch configuration

Here is a snippet of Java code to execute a launch configuration:

import java.io.File;
import com.sodius.mdw.core.CoreException;
import com.sodius.mdw.core.MDWorkbench;
import com.sodius.mdw.core.MDWorkbenchFactory;
import com.sodius.mdw.core.eval.EvaluationManager;
import com.sodius.mdw.core.eval.launch.LaunchConfiguration;

public class LaunchSnippet {

    public static void main(String[] args) throws CoreException {
        
        // Create an MDWorkbench engine
        MDWorkbench mdw = MDWorkbenchFactory.create();
        EvaluationManager manager = mdw.getEvaluationManager();
        
        try {
            // Load a launch configuration
            File file = new File("c:\\deploy\\myLaunch.launch");
            LaunchConfiguration configuration = manager.loadLaunchConfiguration(file);
            
            // Execute the launch configuration
            manager.evaluate(configuration, null);
        }
        finally {
            // Shutdown MDWorkbench (to release licenses)
            mdw.shutdown();
        }
    }
}

Executing the launch configuration

You can run the above snippet of code like any regular Java program. You just have to configure the license source MDWorkbench must use to retrieve its license features. This is done using a System property mdw.license:

java -Dmdw.license=@myServer -classpath <...> LaunchSnippet

This System property value (e.g. @myserver) must match what is set in the MDWorkbench IDE (menu Window > Preferences and MDWorkbench > License). It can be:

LaunchRunner class

Please note that the predefined class LaunchRunner let you execute a launch configuration in a way similar to the above snippet:

java -Dmdw.license=@myServer -classpath <...> 
     com.sodius.mdw.core.eval.launch.LaunchRunner -launch c:\deploy\myLaunch.launch

Related tasks
Changing launch arguments
Customizing log and progress report

Related reference
MDWorkbench interface
EvaluationManager interface