eclipse plugin - Run java code error: Workspace is closed -


To create an automated project, I created a plug-in project with the following dependencies:

    < Li> Org.eclipse.core.resources
  1. org.eclipse.equinox.registry
  2. org.eclipse.core.runtime

and the following The Java class is located in the src folder:

  Package Examiner; Import org.eclipse.core.resources.IProject; Import org.eclipse.core.resources.IWorkspaceRoot; Import org.eclipse.core.resources.ResourcesPlugin; Import org.eclipse.core.runtime.CoreException; Import org.eclipse.core.runtime.IProgressMonitor; Import org.eclipse.core.runtime.NullProgressMonitor; Public class tes {public static zero main (string [] args) {// TODO auto generated method stub IProgressMonitor progress monitor = new NullProgressMonitor (); IWorkspaceRoot root = ResourcesPlugin.getWorkspace (). GetRoot (); Ipoject project = root.jetproject ("desired projectname"); Try {Project.create (progress monitor); Project.open (progressMonitor); } Grip (CoreException E) {// TODO Auto generated blocking block e.printStackTrace (); After running the plugin, I ran the Java class to create a project in the Eclipse application, but gave the following error:  
  Exception thread "main" java.lang.IllegalStateException: Workspace is off. On org.eclipse.core.resources.ResourcesPlugin.getWorkspace (resourcesPlugin.java399) at tester.tes.main (tes.java15)  

What am I doing wrong? And I apologize for my bad English.

You use eclipse resources only the main class of a normal Java program. You must start Eclipse using the eclipse command or by specifying org.eclipse.equinox.launcher.main main category. This is because the workspace can be made available before it requires a lot of initialization.

You must use the org.eclipse.core to run the 'Headless' Eclipse application. Runtime.applications Define the application for the extension to run for the point and application class. Something like this:

  & lt; Extension ID = "appname" point = "org.eclipse.core.runtime.applications" & gt; & Lt; Application cardiology = "singleton-global" thread = "main" view = "true" & gt; & Lt; Run class = "package.application" & gt; & Lt; / Run & gt; & Lt; / Application & gt; & Lt; / Extension & gt;   

You specify this application ID on the eclipse command's -application parameter.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

c - Error on building source code in VC 6 -