OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox)

1. 安装Equinox的core SDK包。Help---Install New Software,根据提示选择已下载的Equinox包,如图:

OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox)_第1张图片


2. 建立一个plug-in project。

OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox)_第2张图片


3. 后面直接next即可。

4. 在项目上右键选择run configuration,关键是target platform。因为新的Eclipse或Equinox与老的有些区别。早一点的例子通常选org.osgi.framework就够了,但新的版本中必须加入其他的依赖,如下图:

OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox)_第3张图片


5. 然后在上图点击run,或者run as OSGi framework即可。

OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox)_第4张图片


TIPs:

1. 与老的例子中的target platform对比。

2. 我在调试过程中出了很多错误,最后分析可能的原因是中文路径问题,部分错误提示如下:

!ENTRY org.eclipse.debug.ui 4 0 2014-11-17 13:25:27.642
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Exception in org.eclipse.debug.internal.ui.DebugUIPlugin.start() of bundle org.eclipse.debug.ui.
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:734)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.start(BundleContextImpl.java:683)
at org.eclipse.osgi.framework.internal.core.BundleHost.startWorker(BundleHost.java:381)
at org.eclipse.osgi.framework.internal.core.AbstractBundle.resume(AbstractBundle.java:390)
at org.eclipse.osgi.framework.internal.core.Framework.resumeBundle(Framework.java:1176)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:559)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.resumeBundles(StartLevelManager.java:544)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.incFWSL(StartLevelManager.java:457)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.doSetStartLevel(StartLevelManager.java:243)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:438)
at org.eclipse.osgi.framework.internal.core.StartLevelManager.dispatchEvent(StartLevelManager.java:1)
at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
at org.eclipse.osgi.framework.eventmgr.EventManager$EventThread.run(EventManager.java:340)
Caused by: java.lang.IllegalStateException: Workbench has not been created yet.
at org.eclipse.ui.PlatformUI.getWorkbench(PlatformUI.java:93)
at org.eclipse.debug.internal.ui.contextlaunching.LaunchingResourceManager.startup(LaunchingResourceManager.java:546)
at org.eclipse.debug.internal.ui.DebugUIPlugin.getLaunchingResourceManager(DebugUIPlugin.java:335)
at org.eclipse.debug.internal.ui.DebugUIPlugin.start(DebugUIPlugin.java:544)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl$1.run(BundleContextImpl.java:711)
at java.security.AccessController.doPrivileged(Native Method)
at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:702)
... 12 more
Root exception:


你可能感兴趣的:(OSGi的Helloworld!(Eclipse-kepler-SR2及对应的Equinox))