0

I have this line of code that returns me null and it should return 9193 which is the value that the property really has in my config.properties file...

System.getProperty("org.osgi.service.http.port") // returns null dunno why

My config.properties has the property correctly set up:

org.osgi.service.http.port=9193

Probably I am missing something here, because it is the first time I try to access those properties. I've googled a lot, so there is lack of examples online or I didn't search for the correct keywords.

What should I add/change to that line to make it return the correct value?

Thanks!

PedroD
  • 5,670
  • 12
  • 46
  • 84

1 Answers1

3

Try to use BundleContext.getProperty. The config.properties are set as OSGi framework properties. So this should be a way to retrieve them.

Christian Schneider
  • 19,420
  • 2
  • 39
  • 64
  • Works! So the resulting code is: @Override public void start(BundleContext context) throws Exception { final String port = context.getProperty("org.osgi.service.http.port"); } Thanks! – PedroD Jan 29 '15 at 18:39