jar libraries for your eclipse plugin

How to add external libraries as jar files in your eclipse plugin

Angelo Gargantini
22 May 2007

We developed a plugin, called asmee, which depends on several libraries, normally individually packaged as jar files. Some of them were internally developed (and we could unpack them and pack again in a bigger jar file), while others (like log4j) were developed externally: we only use them and we don't want (or we can't)  unpack them and pack again since we have to distribute these libraries as they are (as jar files). We wanted to distribute the asmee plugin together with the jar libs: how to do that?

We use eclipse 3.2: in this small tutorial we show how we did.

Add the libraries in the runtime classpath

First of all to run asmee inside eclipse (as eclipse application) we had to add the jar libraries in the runtime classpath. To do this, select the plugin.xml of your plugin and go to the Runtime tab. Add the libraries in Classpath.



Add the libraries in the deployed plugin

To include the libraries in the plugin we have done as follows.
1) add the jars in the binary build: these jars will be packed in the jar file of the plugin:



3) Since the jar file produced for this plugin will contain the jar libraries inside, we want to unpack the zip. This can be done by selection "unpack the plug-in" in the feature project.



How to avoid to unpack the classes of your project

There is also a way to avoid to unpack into classes the jar of your plugin (the . in the binary build tab) and still to have your plugin as jar together with the jars of the libraries, I'll write about that later.

My sw links