Reputation: 2173
My project has two bundles, lets say Bundle A
and Bundle B
.
Now Bundle A
needs to access a class from Bundle B
.
How can I do that?
Upvotes: 3
Views: 2951
Reputation: 662
As @earcam wrote, it is strongly recommended to use Import-Package:
.
Also, always add a version to the exported package in bundle B - this is good practice that you will appreciate later when you create the next version of bundles A and B.
Upvotes: 1
Reputation: 1731
There are two ways:
Require-Bundle: bundle-id-of-bundle-A
Import-Package: package.of.your.class
In both situations, you need to export the package that contains your class in bundle B: Export-Package: package.of.your.class
Also, here's a good intro: http://ctpjava.blogspot.com/2010/09/introduction-to-osgi.html
Upvotes: 6