我一直计划创建一个 Eclipse 应用程序,默认情况下它需要是一个控制台应用程序,但具有 UI(窗口/菜单/ View )作为可选。
大多数时候我需要从命令行运行应用程序,但需要在需要时使用控制台应用程序 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
}
关于java - 制作带有可选 UI 界面的 headless Eclipse 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40881774/