If you want to leverage JDT you have to start eclipse. You can use the extension point "org.eclipse.core.runtime.applications" to create a minimal application that starts from the command line.
- Create a new Plugin-Project.
- Add "org.eclipse.core.runtime" and "org.eclipse.core.resources" to the dependencies.
- Create an extension for "org.eclipse.core.runtime.applications".
- Create a class that implements "org.eclipse.equinox.app.IApplication" and reference it in your extension.
My plugin.xml looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="id2"
point="org.eclipse.core.runtime.applications">
<application
cardinality="singleton-global"
thread="main"
visible="true">
<run class="testapplication.Application1">
</run>
</application>
</extension>
</plugin>
MANIFEST.MF:
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: TestApplication
Bundle-SymbolicName: TestApplication;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: testapplication.Activator
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Application1.java:
package testapplication;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
public class Application1 implements IApplication {
@Override
public Object start(IApplicationContext context) throws Exception {
System.out.println("Hello eclipse at "
+ ResourcesPlugin.getWorkspace().getRoot().getRawLocation());
return IApplication.EXIT_OK;
}
@Override
public void stop() {
// nothing to do at the moment
}
}
Output is:
Hello eclipse at D:/Arne/workspaces/runtime-TestApplication.id2