mur
mur

Reputation: 51

eclipse workspace is closed problem

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)

Upvotes: 1

Views: 3877

Answers (3)

Fábio
Fábio

Reputation: 193

If you want to run your application like this it must be headless. Following you can see how to create a headless project: Going Headless

Upvotes: 0

Fabian Steeg
Fabian Steeg

Reputation: 45754

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.

Upvotes: 0

Nikolay Ivanov
Nikolay Ivanov

Reputation: 8935

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.

Upvotes: 1

Related Questions