Workspace, Workbench and Refresh

Workspace

One of the first things you specify when you start Eclipse is the workspace location. The workspace is a directory which holds information about the projects you work on, as well as the Eclipse preferences (from layout to behavior). We can say that the workspace "holds" the Integrated Development Environment: the data you work on (organized in projects) and how you work with it (preferences). It is your "space of work" or "working space" or "working universe".

Depending on your style, you can do all your work in a single workspace, no matter how different projects in your life (a Web project to publish your photos + a Verification project + a Java project where you learn how to program). Or you can chose to have several workspaces, each one dedicated to a specific state of mind or universe of thinking.

Work

Workspace and workbench are different terms for different concepts, however they sound quite similar to be mistakenly interchanged (the "work" prefix has a tendency to make us lose the interest, so I guess we don't get to hear clearly the "space" or "bench" that follow, hence both workspace and workbench collapse under the annoying "something about work").

Workbench

The workbench is practically the Eclipse main window. It is the bench where you organize your instruments, except that now you don't have power supplies, signal generators or oscilloscopes, but different views and editors. Views and editors are your instruments to manipulate sources and data. You arrange them at hand for a specific task (exploring, debugging, coding etc.). What instruments you use and how you lay them out on your bench (workbench) is known as a perspective: with what and from what angles you look at your data. Eclipse allows you quickly to reorganize your workbench, by choosing a different perspective. Don't have to spend time moving the signal generator away, just switch to another perspective.

Workspace Again

The projects (your data) are not necessarily physically located in the workspace directory. They can be simple pointers to other locations on the disk. However the workspace aggregates all your "relevant" projects for a specific development universe.

When you create a new empty project in the workspace, it is located in the actual workspace directory. When you create a project from existing source, the workspace keeps a pointer to the project definition, which is located in the existing source root directory. When you import a project in your workspace, again the workspace keeps a pointer to the actual project definition. (Importing is an interesting concept, documented separately).

You can switch at any time from one workspace to another (menu File > Switch workspace...). You can start several Eclipse instances looking at various workspaces (chose when prompted at start or in batch mode "eclipse -d <workspace location>"). However, you cannot have two Eclipse instances looking at the same workspace at once. Eclipse locks the workspace, as indicated by the .metadata/.lock file in the workspace directory.

Refresh

Once you start Eclipse, the workspace is usually read from the disk (not necessarily, caches are also kept from the previous invocation). From this point on, usually, what ever changes you do outside of Eclipse on resources in the workspace are not reflected immediately. You need to request for a refresh (right click on a project and chose Refresh from the drop down menu).

"Usually" above because it can be customized. To customize the way refresh behaves and eventually switch it to fully detect each change whenever it occurs, use menu Window > Preferences > General > Workspace. From here you can customize if refresh is done on startup, how often etc.

Refresh is a basic and primitive support of concurency and also has to do with performance. Maybe I don't want to be notified of every change on resources in my projects if somebody is also processing part of the data outside Eclipse. It may take a while, even not be relevant and stop me from working until the external processing is complete. For example compilation. Hence maybe I want to trigger it when I know for sure I am interested in some external changes. This does not imply that conflicts (for example editing a file which changed on the disk) are not promptly signaled by Eclipse.

It happens often that you don't find some files in your workspace (of course inside a project) although from explorer or console it seems they are there. Maybe you foregot to refresh?

Related Reference

What is a Workspace?

What is a Project?