我正在尝试做一个非常简单的 OSGi 测试,但我无法让它工作。似乎 OSGi 运行时找不到我的激活器类。有什么线索吗?
激活器.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-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