问题
Upon invoking the method PlatformUI.getWorkbench().restart() the application is simply closing and refusing to restart the product.
回答1:
Your IApplication needs to check the return code from PlatformUI.createAndRunWorkbench in the start method:
The simplest is:
int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);
if (returnCode == PlatformUI.RETURN_RESTART)
return IApplication.EXIT_RESTART;
return IApplication.EXIT_OK;
More recent applications seem to use this:
private static final String SYSTEM_PROPERTY_EXIT_CODE = "eclipse.exitcode";
int returnCode = PlatformUI.createAndRunWorkbench(display, advisor);
if (returnCode == PlatformUI.RETURN_RESTART)
{
// eclipse.exitcode system property may be set to re-launch
if (IApplication.EXIT_RELAUNCH.equals(Integer.getInteger(SYSTEM_PROPERTY_EXIT_CODE)))
return IApplication.EXIT_RELAUNCH;
return IApplication.EXIT_RESTART;
}
return IApplication.EXIT_OK;
来源:https://stackoverflow.com/questions/24890851/eclipse-restart-using-platformui-getworkbench-restart-is-not-restarting-th