Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically/ automatically run OSGi applications

Tags:

java

eclipse

osgi

When creating Java OSGi projects in eclipse, you run them by .bndrun-> Run OSGi (for example)

This does not seem to be really workable when you want to distribute your application to a client, since it would be an inconvenience for them to go about having to manually run the bundles in an OSGi container.

Is there a way I could have a "main" jar\ bundle with a public static void main(String[] args) {} class that automatically starts an OSGi container and loads the bundles, as if it was all in one jar file, when a user runs this file?

like image 883
Program-Me-Rev Avatar asked Jul 18 '26 00:07

Program-Me-Rev


2 Answers

See the OSGi enRoute site. The Quick Start tutorial and the Base tutorial explain how to export to an executable JAR. If you use Maven, see the Eval example.

like image 79
Peter Kriens Avatar answered Jul 20 '26 15:07

Peter Kriens


You can simply use the export button in bndtools. It creates a runnable jar that you can distribute.

Bndtools also supports an automated build using gradle.

Recently bndtools also has maven support see this example.

like image 33
Christian Schneider Avatar answered Jul 20 '26 15:07

Christian Schneider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!