dcb
dcb

Reputation: 2292

OSGi console not shown in command line

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:

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.

Upvotes: 1

Views: 2025

Answers (2)

Frédéric
Frédéric

Reputation: 583

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

Upvotes: 1

dcb
dcb

Reputation: 2292

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.

Upvotes: 0

Related Questions