Skip to content
This repository has been archived by the owner on Dec 9, 2018. It is now read-only.

Program Arguments

fhuberts edited this page Apr 25, 2013 · 4 revisions

This page describes how to access the program arguments, a.k.a. the command line arguments.

Preconditions

  • You use Declarative Service (DS)
  • You use the bnd DS annotations

Notes

  • The functionality to set the program arguments in the bnd editor on the Run tab is included in the 2.1.0 release

Code

  /*
   * Command line arguments
   */

  private static final String LAUNCHER_ARGUMENTS = "launcher.arguments";

  private String[] args = null;

  /*
   * The bnd launcher provides access to the command line arguments via the
   * Launcher object. This object is also registered under Object.
   */
  @Reference
  protected void setDone(@SuppressWarnings("unused") Object done, Map<String, Object> parameters) {
    args = (String[]) parameters.get(LAUNCHER_ARGUMENTS);
  }