VamsiKrishna
VamsiKrishna

Reputation: 791

how to get Eclipse Workspace Location URI

I am working on a plugin, which passes the location URI of current workspace to other method.

IWorkspace workspace = ResourcesPlugin.getWorkspace();

I am very new to Eclipse PDE. What method returns the URI location of workspace. for Ex if the workspace is C:\Eclipse\Workspace. i need the path C:\Eclipse\Workspace

Upvotes: 9

Views: 12293

Answers (3)

Eugene
Eugene

Reputation: 9474

Are you sure you need workspace URL? The only thing you may rely is that it will contain .metadata folder - everything else may be located elsewhere:

  1. Projects can be created outside of the workspace.
  2. Workspace files/folders may actually be a links to external resources (that might not even be local files).

My recommendation:

  1. If you want to find some resources - use IResource::getLocationURI and check that it is a local file (you may download the content if the URL is EFS)
  2. If you want to access your plugin data (that is in .metadata) use Plugin.getStateLocation
  3. If you still think you need workspace root - Platform.getInstanceLocation

Upvotes: 6

Chris Gerken
Chris Gerken

Reputation: 16392

You want:

ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();

Upvotes: 14

elo
elo

Reputation: 615

Get the absolute file system path of any resource:

IResource.getLocation() 

Upvotes: 1

Related Questions