1

I'm trying to get an OSGi example application working, but I'm running into trouble while starting OSGi from the command line.

Note that I don't want to run the bundle in the Eclipse OSGi environment. This works fine.


First, I created the example bundle. Afterwards, I tried to run the the application in the command line. To do so, I run the OSGi jar as stated in the above-mentioned article, official instructions and a related question:

$ 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

Now, OSGi seems to run, but the console is not shown.


According to the above-mentioned article (see Section 4.2) and a related question with solution, the following additional packages are required:

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

Are they missing? If yes, how do I link them?


My question: How can I run OSGi with console in the command line?

Thanks for any help!

EDIT 1: $ eclipse -console -noExit and closing the IDE works as a workaround :-) sadly, IDE bundles are loaded this way as well.

Community
  • 1
  • 1
aboger
  • 2,214
  • 6
  • 33
  • 47
  • 1
    So you already linked to the question with the solution. Did you try that? – Neil Bartlett Sep 29 '13 at 16:54
  • What I tried was `java -jar org.eclipse.equinox.console_VERSION.jar`, also called adding `-console`. Ended up in `no main manifest attribute, in org.eclipse.equinox.console_1.0.0.v20120522-1841.jar`. Do I _link_ the bundles? – aboger Sep 29 '13 at 17:00
  • To run with Equinox check http://stackoverflow.com/questions/25733843/how-to-start-osgi-console-equinox – Paul Verest Apr 10 '16 at 14:30

2 Answers2

1

Here is a generic command to have it working with Equinox implementation on both Unix and Windows systems.

Tested with an install of Eclipse 2018-12, however it should work with other versions as well.

Go to the plugin directory

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 (works in console mode only):

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 (works with ISE as well):

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 '')

Link to the eclipse bug:
Bug 371101 - Equinox console doesn't start

Frédéric
  • 565
  • 1
  • 5
  • 10
0

A workaround is not to run Equinox implementation of OSGi Apache Felix Framework as stated in the mentioned related question:

  • Download the framework.
  • Unzip the framework
  • Run the following command:

$ java -jar bin/felix.jar


Anyway, this seems to be a workaround to me and I'm still interested in how to use the Equinox framework from the command line.

Community
  • 1
  • 1
aboger
  • 2,214
  • 6
  • 33
  • 47