【问题标题】:OSGi console not shown in command line命令行中未显示 OSGi 控制台
【发布时间】:2013-10-05 11:12:21
【问题描述】:

我正在尝试让OSGi example application 工作,但是在从命令行启动 OSGi 时遇到了麻烦。

请注意,我不想在 Eclipse OSGi 环境中运行该包。这很好用。


首先,我创建了示例包。之后,我尝试在命令行中运行该应用程序。为此,我按照上述文章 official instructionsrelated question 中的说明运行 OSGi jar:

$ cd
$ cp /usr/local/eclipse/plugins/org.eclipse.osgi_3.8.2.v20130124-134944.jar
     org.eclipse.osgi.jar
$ java -jar org.eclipse.osgi.jar -console

现在,OSGi 似乎可以运行,但没有显示控制台。


根据上述文章(见第4.2节)和a related question with solution,需要以下附加包:

  • org.eclipse.equinox.console
  • org.apache.felix.gogo.command
  • org.apache.felix.gogo.runtime
  • org.apache.felix.gogo.shell

他们失踪了吗?如果是,我该如何链接它们?


我的问题:如何在命令行中使用控制台运行 OSGi?

感谢您的帮助!

编辑 1:$ eclipse -console -noExit 并关闭 IDE 作为一种解决方法 :-) 遗憾的是,IDE 包也以这种方式加载。

【问题讨论】:

  • 所以您已经通过解决方案链接到问题。你试过了吗?
  • 我试过的是java -jar org.eclipse.equinox.console_VERSION.jar,也叫加-console。结束于no main manifest attribute, in org.eclipse.equinox.console_1.0.0.v20120522-1841.jar。我是否链接捆绑包?

标签: java osgi


【解决方案1】:

这是一个通用命令,可以让它在 Unix 和 Windows 系统上与 Equinox 实现一起工作。

已安装 Eclipse 2018-12 进行测试,但它也应该适用于其他版本。

进入插件目录

Unix、bash:

java -Dosgi.bundles=\
$(ls -1 org.apache.felix.gogo.shell_*.jar)@start,\
$(ls -1 org.apache.felix.gogo.command_*.jar)@start,\
$(ls -1 org.apache.felix.gogo.runtime_*.jar)@start,\
$(ls -1 org.eclipse.equinox.console_*.jar)@start\
 -jar $(ls -1 org.eclipse.osgi_*.jar) -console

Windows、powershell(仅在控制台模式下工作):

java ('-Dosgi.bundles='+((`
"$(ls org.apache.felix.gogo.shell_*.jar | select -ExpandProperty Name)`@start",`
"$(ls org.apache.felix.gogo.command_*.jar | select -ExpandProperty Name)`@start",`
"$(ls org.apache.felix.gogo.runtime_*.jar | select -ExpandProperty Name)`@start",`
"$(ls org.eclipse.equinox.console_*.jar | select -ExpandProperty Name)`@start"`
) -join ',')) '-jar' "$(ls org.eclipse.osgi_*.jar | select -ExpandProperty Name)" '-console'

Windows、powershell(也适用于 ISE):

Start-Process 'java' -ArgumentList `
(('-Dosgi.bundles=',`
"$(ls org.apache.felix.gogo.shell_*.jar | select -ExpandProperty Name)`@start,",`
"$(ls org.apache.felix.gogo.command_*.jar | select -ExpandProperty Name)`@start,",`
"$(ls org.apache.felix.gogo.runtime_*.jar | select -ExpandProperty Name)`@start,",`
"$(ls org.eclipse.equinox.console_*.jar | select -ExpandProperty Name)`@start",`
" -jar $(ls org.eclipse.osgi_*.jar | select -ExpandProperty Name) -console"
) -join '')

eclipse bug 链接:
Bug 371101 - Equinox console doesn't start

【讨论】:

    【解决方案2】:

    解决方法是不运行 OSGi Apache Felix Framework 的 Equinox 实现,如提到的 related question 中所述:

    • 下载框架。
    • 解压框架
    • 运行以下命令:

    $ java -jar bin/felix.jar


    无论如何,这对我来说似乎是一种解决方法,我仍然对如何从命令行使用 Equinox 框架感兴趣。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-12-21
      • 2016-05-19
      • 1970-01-01
      相关资源
      最近更新 更多