tags:

views:

238

answers:

2

Hi

How to get access to eclipse workspace from java program. When I use IWorkspace workspace = ResourcesPlugin.getWorkspace().getRoot() it gives me exception like this

java.lang.IllegalStateException: Workspace is closed.
  at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:329)
  at amdocs.amsp.test.EMFCodeGen.load(EMFCodeGen.java:37)
  at amdocs.amsp.test.EMFCodeGen.main(EMFCodeGen.java:26)

can you tell me how to get access to workspace from a standalone java program out side of eclipse. (of ourse there is a classpath with all the jar required for that)

+1  A: 

Are you trying to do it in OSGi based application (eqinox for example)? Because workspace is created upon start of org.eclipse.core.resources bundle that should be managed by framework, exception of yours means that bundle probably didn't start yet.

Nikolay Ivanov
A: 

As far as I understand this, the workspace retrieved with ResourcesPlugin.getWorkspace() is the workspace the running Platform is using, if Platform.isRunning(). So if you are running a plain Java application, not an Eclipse application, there is no such thing as the workspace.

Fabian Steeg