我創建了一個非常簡單的包:Swing應用程序和OSGi費利克斯
public class Main implements BundleActivator, ServiceListener{
public void start(BundleContext bc) throws Exception {
bc.addServiceListener(this);
//trivial system out
System.out.println("started");
//output to file
FileWriter fw = new FileWriter("test.txt");
fw.write("it has worked");
fw.close();
//opening of a frame
JFrame f = new JFrame();
JLabel l = new JLabel("test");
f.add(l);
f.setVisible(true);
f.pack();
}
(other methods with empty body)
我已經編輯清單文件:
Bundle-Name: Service listener example
Bundle-Description: A bundle that displays messages at startup and whe service events occur
Bundle-Vendor: Apache Felix
Bundle-Version: 1.0.0
Bundle-Activator: tosgi01.Main
Import-Package: org.osgi.framework
我jar'ed了這一切的東西,推出felix和: 開始文件:testosgi.jar
它不會給出錯誤,但不起作用。 有沒有辦法獲得關於發生了什麼的一些詳細信息?
我覺得這個鏈接[http://www.javacodegeeks.com/2012/04/osgi-modularizing-your-application.html](http://www.javacodegeeks.com/2012/04/osgi-modularizing -your-application.html)爲您提供更好的解決方案。 –