Search code examples
linuxeclipseworkspace

How to get workspace programmatically?


any one know how can I get current path of eclipse workspace programmatically. Since this path changes in every computer I want to get this thing programmatically and dynamically. It should return a string and it should be like ersin/projects/proj/my_work_space_name.

by the way this code didnt work for me: ResourcesPlugin.getWorkspace().getRoot().getLocation().toString() it gives ersin/projects/proj/runtime-EclipseApplication whereas it should be ersin/projects/proj/my_work_space_name.


Solution

  • It looks like you're getting that value because you're running a test environment for debugging a plugin. When you do that, you're effectively running a different workspace and that's why you're getting the root location of that workspace. Should you get to the point where you run that plugin in your original development workspace, you'll get the value you expect.

    In short, you are getting the current path of the eclipse workspace.

    So if you're trying to debug a plugin that searches the workspace, you'll need to add projects to your test workspace so that the search can take place there.