I am new in eclipse plugin development. I want to refresh my workspace or complete Eclipse programmatically . so is there any to refresh eclipse programmatically.
Asked
Active
Viewed 1.9k times
20
-
2[This](http://blog.pengoworks.com/index.cfm/2008/6/30/Refreshing-Eclipse-Workspace-using-ANT) can help you. – Harry Joy Mar 29 '11 at 04:38
-
@Harry Joy : thanks it's exactly what i needed, refresh eclipse within ant script. – Jean-Christophe Blanchard Jan 23 '13 at 08:46
-
Possible duplicate of [Refresh an Eclipse project with Ant](https://stackoverflow.com/questions/985976/refresh-an-eclipse-project-with-ant) – Ahmad Nadeem Oct 31 '17 at 06:10
-
If it's just about ant: You may not even have to program anything: Several kinds of launch configurations, including those for `Ant Build`, have a tab `Refresh` that lets you select what exactly should be refreshed after completion. – Stephan Herrmann Oct 31 '17 at 19:22
2 Answers
21
Use the IResource.refreshLocal()
API. You can do this at project root, a particular folder or an individual file. To refresh all projects in a workspace, simply enumerate all projects using ResourcesPlugin.getWorkspace().getRoot().getProjects()
API and refresh each in turn.

mtsz
- 2,725
- 7
- 28
- 41

Konstantin Komissarchik
- 28,879
- 6
- 61
- 61
-
I get IllegalStateException that the workspace is closed. How to solve this problem? – Md Johirul Islam Nov 30 '16 at 05:22
7
Here is a quick snippet to refresh each project in the Eclipse workspace.
for(IProject project : ResourcesPlugin.getWorkspace().getRoot().getProjects()){
project.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
}

Ben Holland
- 2,309
- 4
- 34
- 50
-
I get IllegalStateException that the workspace is closed. How to solve this problem? – Md Johirul Islam Nov 30 '16 at 05:22
-
Could be a few things. Are you running Eclipse in a headless way by chance? If so make sure you've actually made a workspace. Also check your plugin manifest settings, try reading this post: https://stackoverflow.com/questions/962364/workspace-is-closed-exception-when-trying-to-get-the-workspace-through-resourc – Ben Holland Dec 03 '16 at 21:27