2
votes

I have developed two eclipse plugins, EAXMLModelExchange and EAXMLModelExchangeWizard.

I want to call a public static method EAXMLExchange.convertEAModelToEAXml(String, String) in the plugin EAXMLModelExchangeWizard.

The class are located in the package eaxmlmodelexchange.

How the method is called. import eaxmlmodelexchange.EAXMLExchange;

It work when I run the project as Eclipse Application but when I export it to .jar files the method dosen't get called.

public void runFunction() {
   EAXMLExchange.convertEAModelToEAXml(String, String);
}

The MANIFEST.MF in EAXMLModelExchange

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: EAXMLModelExchange
Bundle-SymbolicName: EAXMLModelExchange;singleton:=true
Bundle-Version: 1.0.0
Require-Bundle: org.eclipse.core.runtime,
 org.eclipse.sphinx.emf;bundle-version="0.7.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: eaxmlmodelexchange

MANIFEST.MF in EAXMLModelExchangeWizard

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: EAXMLModelExchangeWizard
Bundle-SymbolicName: EAXMLModelExchangeWizard;singleton:=true
Bundle-Version: 1.0.0
Bundle-Activator: eaxmlexchangewizard.Activator
Require-Bundle: org.eclipse.ui,
 org.eclipse.core.runtime,
 org.eclipse.core.resources,
 org.eclipse.ui.ide,
 org.eclipse.sphinx.emf;bundle-version="0.7.0",
 EAXMLModelExchange;bundle-version="1.0.0"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

Does anyone know how to get it to work?

2
Interesting question, hopefully someone will give an elaborate answer - Viktor Mellgren
This should work. Is there an exception thrown when trying to call the method? Might you not have exported org.eclipse.sphinx.emf or one of its dependencies along with your plugins? - Alexey Romanov

2 Answers

0
votes

One technique you can use to see what error is being thrown is to write any exceptions to the Eclipse log. The Error Log view lets you view and clear the log.

try {
    EAXMLExchange.convertEAModelToEAXml("Hello", "World");
} catch (Exception e) {
    IStatus status = new Status(Status.ERROR,"EAXMLModelExchangeWizard","Error calling other plugin",e);
    Activator.getDefault().getLog().log(status);
}
0
votes

There are some clarifications required.

When you said you have exported them as jar files, is that means plugin jars and you have placed them in eclipse environment? (like dropins folder)
If not.... If you are calling as simple java applications then the dependencies will not be known to each other. You have to put both of them in the class path before calling or MANIFEST.MF file of one jar should be added with extra option Class-Path: < name of the other dependent jar>