'Add external jars to Eclipse plugin classpath

In the manifest file for an eclipse plugin its possible to add jar files and folders to the classpath (on the Runtime tab).

In the root of my plugin I have a folder lib containing a-1.0.1.jar, b-1.0.0-SNAPSHOT.jar. But only when I select each jar separately:

Bundle-ClassPath: .,
 lib/a-1.0.1.jar,
 lib/b-1.0.0-SNAPSHOT.jar

...can they be used inside my project. Why is it not possible to add them to the classpath by adding the common root folder only:

Bundle-ClassPath: .,
 lib/

?



Solution 1:[1]

No, you can't. Eclipse is based on OSGi, which is the platform providing MANIFEST.MF support to build plugins.

When you set values under Bundle-ClassPath, OSGi search into each one to find class files. So you can put folders containing Java packages and class files. When you put a jar file, it is uncompressed in memory and viewed by OSGi as a regular folder, still searching for class files.

Unfortunately, there is no way to load all jar from a folder. No wildcard mechanism or something like that is allowed here.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lii