Adding extra system properties to an Eclipse programmatic restart

吃可爱长大的小学妹 提交于 2021-02-10 13:17:10

问题


I have a plugin that forces a restart of Eclipse by using:

Workbench.getInstance().restart();

However, I need this restart to include a new environment variable:

eclipse.refreshBundles=true

Is there any way to add such an environment variable for this next restart of Eclipse only?


回答1:


Eclipse has 2 modes for restarting: "restart" using the previous command line, or "relaunch" using a new command line. The launcher itself will remember the previous command line, so in order to add a new system property, you will need to do the relaunch.

The restart/relaunch is part of the IApplication API, the Workbench.restart() will cause the IDEApplication to return relaunch if you set the system property eclipse.exitcode=24.

For the relaunch, you need to put the new command line in the eclipse.exitdata system property. You will need to reconstruct the command line using the eclipse.commands and eclipse.vmargs system properties, and add a -Declipse.refreshBundles=true vm argument. For an example of this, take a look at OpenWorkspaceAction in org.eclipse.ui.ide which uses the relaunch to switch workspaces.

Note that in the restarted eclipse, the eclipse.refreshBundles will be part of the command line, and will remain there for further restarts unless you modify the system properties. It will be gone if you exit fully and start again.



来源:https://stackoverflow.com/questions/1539601/adding-extra-system-properties-to-an-eclipse-programmatic-restart

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!