Equinox 3.8.1的命令行启动

由于很多网上文档说的直接运行java -jar org.eclipse.osgi.xx.jar来启动的方式实际上不会启动org.eclipse.console所以并不能在命令行显示和交互,虽然启动了OSGi容器但是使用者无法交互和操作,唯一能看到的就是日志中报错。所以自己尝试成功后记录下来,以备回顾。

1,从Eclipse安装目录找出OSGi启动并输出到命令行的所有jar:

org.eclipse.osgi_3.8.1.v20120830-144521.jar
org.eclipse.equinox.console_1.0.0.v20120522-1841.jar
org.apache.felix.gogo.runtime_0.8.0.v201108120515.jar
org.eclipse.osgi.services_3.3.100.v20120522-1822.jar
org.apache.felix.gogo.shell_0.8.0.v201110170705.jar
org.apache.felix.gogo.command_0.8.0.v201108120515.jar
org.eclipse.osgi.util_3.2.300.v20120522-1822.jar

很奇怪,这里面为什么有felix的jar包,而且是在eclipse的安装目录中找到的,可能是eclipse放弃了自家的交互shell,直接吸收felix的功能了?

2,编写启动equinox的配置,也就是设定各个jar的启动顺序,否则equinox不会加载bundle。在目录中找到或新建子目录configuration,该目录下简历config.ini文件,内容如下:
osgi.bundles=org.eclipse.equinox.console_1.0.0.v20120522-1841.jar@start ,\
org.apache.felix.gogo.runtime_0.8.0.v201108120515.jar@start ,\
org.eclipse.osgi.services_3.3.100.v20120522-1822.jar@start ,\
org.apache.felix.gogo.shell_0.8.0.v201110170705.jar@start ,\
org.apache.felix.gogo.command_0.8.0.v201108120515.jar@start ,\
org.eclipse.osgi.util_3.2.300.v20120522-1822.jar@start

3,命令行启动输入命令:java -jar org.eclipse.osgi_3.8.1.v20120830-144521.jar -console
启动成功,显示osgi>。
这里奇怪的问题是在没有配置2步骤时,启动osgi会在日志里报错找不到bundle org.eclipse.equinox.console,很是神奇。难道org.eclipse.osgi不完全是自包含的,它知道自己要依赖equinox.console的包?

你可能感兴趣的:(osgi,equinox)