I created an Eclipse 4 application and I needed a jar
offering a functionality as part of my application (this could be anything e.g. log4j
to make it trivial).
I added the jar
as part of my project's classpath (Right Click->Configure Build Path
) but on runtime my service failed with a ClassNotFound
error (from OSGI I guess?).
Anyway searching this it turned out, at least as I have understand it, that I should add the jar as part of another Plugin
and create a dependency from my application/service to this new plugin.
I.e. I created a Plugin Project from Existing JAR archives
.
This time the setup worked.
So if I understand this, when developing for Eclipse/OSGi we should not add jars
in the classpaths directly but add them via plugins (why?).
Question: If I am correct so far, what is the standard practice to include jars
when developing a project?
Define/Create one Plugin Project from existing JAR archives
and add all the required third party libraries needed there, or have a different plugin project per needed jar
or something else perhaps???
Sorry if my terminology is not accurate. I am new in OSGi and Eclipse programming
Note: When talking about jars
I am not refering to other OSGi services. I am refering to the norm of using ready, reliable third party libraries that would be needed by many parts of an application. E.g. log4j
or an xml parsing library or apache commons
etc