public class MyModule implements BundleActivator {
@Override
public void start(BundleContext context) throws Exception {
System.out.println("MyModule started");
}
@Override
public void stop(BundleContext context) throws Exception {
System.out.println("MyModule stopped");
}
}
FrameworkFactory frameworkFactory = new FrameworkFactory();
Framework framework = frameworkFactory.newFramework();
framework.start();
BundleContext bundleContext = framework.getBundleContext();
Bundle bundle = bundleContext.installBundle("file:./my-module.jar");
bundle.start();
framework.stop();