使用可选的 UI 接口制作无头 eclipse 应用程序

Making a headless eclipse application with optional UI interface

我一直在计划创建一个 eclipse 应用程序,默认情况下它需要是一个控制台应用程序,但 UI (window/menu/views) 是可选的。

大部分时间我需要从命令行运行应用程序,但需要使用控制台应用程序 take 命令来启用UI。

任何人都可以指导我如何通过 Eclipse 配置此类应用程序的正确资源吗?

谢谢。

我不认为一旦应用程序启动就可以完成此操作。

对于实现 IApplication 的 3.x 兼容模式 RCP,您可以检查命令行参数以了解在 start 方法中需要哪种启动类型:

@Override
public Object start(final IApplicationContext context) throws Exception
{
  String [] args = (String [])context.getArguments().get(IApplicationContext.APPLICATION_ARGS);

  // TODO scan args for an option telling you which start is required

  // TODO If GUI required call PlatformUI.createAndRunWorkbench in the usual way
  // TODO otherwise do console app
}