1
我試圖做一個非常簡單的OSGi測試,但我無法得到它的工作。看起來OSGi運行時無法找到我的激活器類。任何線索?這個測試包爲什麼會失敗?
Activator.java:
package test;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
public class Activator implements BundleActivator
{
public void start(BundleContext context) throws Exception
{
System.out.println("Hello world");
}
public void stop(BundleContext context) throws Exception
{
System.out.println("Goodbye World");
}
}
MANIFEST.MF
Manifest-Version: 1.0
Bundle-Name: Test
Bundle-SymbolicName: Test
Bundle-Version: 1.0.0
Bundle-Activator: test.Activator
Import-Package: org.osgi.framework
我編譯和打包我的激活與
$ javac -classpath /usr/share/java/org.eclipse.osgi.jar Activator.java
$ jar cmf MANIFEST.MF test.jar Activator.class
與運行的OSGi
$ java -jar /usr/share/java/org.eclipse.osgi.jar -console
$ osgi> install file:///home/august/Documents/prog/java/osgi/test/test.jar
Bundle id is 1
$ osgi> start 1
org.osgi.framework.BundleException: The activator test.Activator for bundle Test is invalid
at org.eclipse.osgi.framework.internal.core.AbstractBundle.loadBundleActivator(AbstractBundle.java:171)
...
at java.lang.Thread.run(Thread.java:679)
Caused by: java.lang.ClassNotFoundException: test.Activator
啊,當然。謝謝! – 2012-04-08 19:07:11