Eclipse rcp 在RCP应用程序中读取程序参数?

Eclipse rcp 在RCP应用程序中读取程序参数?,eclipse-rcp,Eclipse Rcp,我已经创建了一个eclipse应用程序和一个产品配置 在启动选项卡上的产品配置中,可以指定程序参数和VM参数 是否可以从应用程序类访问这些参数?当前该类的外观如下所示: public class Application implements IApplication { @Override public Object start(IApplicationContext context) throws Exception { Map<?, ?> arguments =

我已经创建了一个eclipse应用程序和一个产品配置

在启动选项卡上的产品配置中,可以指定程序参数和VM参数

是否可以从应用程序类访问这些参数?当前该类的外观如下所示:

public class Application implements IApplication {

  @Override
  public Object start(IApplicationContext context) throws Exception {
    Map<?, ?> arguments = context.getArguments(); // this is empty!

    // This actually does the trick but is a bit ugly - must be parsed
    String[] strings = (String[]) context.getArguments()
    .get("application.args");

    Display display = PlatformUI.createDisplay();
    try {
      ApplicationWorkbenchAdvisor advisor = new ApplicationWorkbenchAdvisor();
      int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);
      if (returnCode == PlatformUI.RETURN_RESTART) {
        return IApplication.EXIT_RESTART;
      } else {
        return IApplication.EXIT_OK;
      }
    } finally {
      display.dispose();
    }

  }


  /*
   * (non-Javadoc)
   * 
   * @see org.eclipse.equinox.app.IApplication#stop()
   */
  @Override
  public void stop() {
    final IWorkbench workbench = PlatformUI.getWorkbench();
    if (workbench == null) {
      return;
    }
    final Display display = workbench.getDisplay();
    display.syncExec(new Runnable() {
      @Override
      public void run() {
        if (!display.isDisposed()) {
          workbench.close();
        }
      }
    });
  }
只是

请参阅以获取示例。

仅此而已

有关示例,请参见

// This actually does the trick but is a bit ugly
String[] strings = (String[]) context.getArguments()
.get("application.args");
Platform.getCommandLineArgs();