User Tools

Site Tools


This is an old revision of the document!

Headless Eclipse

What Is It?

A “Headless Eclipse” is an instance of Eclipse launched without any Graphical User Interface, on the command-line.

What For?

You can use a Headless Eclipse to call a plug-in in Eclipse from some external programs. One of the purposes of such a call, as seen with SQUANER, is to automatically delegate processing to Eclipse from a Web application. Indeed, to create the PADL model of a C++ project, SQUANER asks Eclipse to parse the C++ project and to return its model.

How to Use It?

First, create your plug-in with the Eclipse IDE, within the Plug-in Development Environment (PDE). In the plugin.xml file of your plug-in (root level of the project), give a specific ID to your plugin. You should have a file like this:

<?xml version=“1.0” encoding=“UTF-8”?> <?eclipse version=“3.4”?> <plugin> <extension id=“Id_of_the_plugin” point=“org.eclipse.core.runtime.applications”> <application cardinality=“singleton-global” thread=“main” visible=“true”> <run class=“Package_name.Starting_class_name”> </run> </application> </extension> </plugin>

Then, download a second Eclipse that will be used to run your plug-in, i.e., the Headless Eclipse. From the first Eclipse IDE, export your plugin (right-click on your plugin project > Export > Plug-in Development > Deployable plug-ins and framents). Check all needed plugins and export them to the eclipse root folder of your Headless Eclipse (the plugins will automatically be put in the plugins folder).

Finally, open a shell on the eclipse root folder of your Headless Eclipse and use the following command:

java -cp plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar org.eclipse.equinox.launcher.Main -application Name_of_your_plugin_project.Id_of_the_plugin

The version of the JAR archive may change in time; just check the name of the library eclipse/plugin/org.eclipse.equinox.launcher_* and modify the command consequently.

Known Problems

1. Application Name_of_your_plugin_project.Id_of_the_plugin could not be found in the registry

If you see this error in the log file, after launching your headless application, in most cases it means you may have a dependendy issue. Check all the manifest files of your plugin projects and localize all needed resources. Let's remind than a plugin should only depend on other plugins. Not a Java project, not an external library… If you need to use a library, you can create a plugin from the library (in Eclipse IDE, right-click on the Package Exporer > New > Other > Plug-in Development > Plug-in from Existing JAR Archives). Then let your plugin depend on the freshly plug-ined library thanks to the Manifest > Dependencies tab > Required Plug-ins.

2. java.lang.NoClassDefFoundError

It happens that if you use the plugin automatic export, some archives do not contain the class definitions… One solution is to manually export a jar archive of the project with needed class definitions, and rename it to replace the empty archive. One anti-solution is to add the manually exported archive in the class path.

Created by angelino 2012/08/22 11:42

headless_eclipse.1398937911.txt.gz · Last modified: 2017/09/06 01:54 (external edit)