Manifest:
Manifest-Version: 1.0
Bundle-Name: Mahjong
Bundle-Activator: MahjongActivator
Bundle-SymbolicName: Mahjong
Bundle-Version: 1.0.0
Import-Package: org.osgi.framework
Compiling & jarring:
$ javac -classpath equinox.jar src/start/*java
$ jar -cfm Mahjong.jar MahjongManifest.mf src/start/*class
The activator:
package start;
import org.osgi.framework.*;
public class MahjongActivator implements BundleActivator
{
public void start(BundleContext context)
{
System.out.println("Hi!");
}
public void stop(BundleContext context)
{
System.out.println("Bye!");
}
}
Then I load the .jar in OSGi and when I try to start() it, it says:
org.osgi.framework.BundleException: The activator MahjongActivator for bundle Mahjong is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:156)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:751)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:370)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:284)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.start(AbstractBundle.java:276)
...
Caused by: java.lang.ClassNotFoundException: MahjongActivator
...
some more ClassNotFounds...
Why?
It should be “Bundle-Activator: start.MahjongActivator” — you’ve omitted the package name.