title: Run java code error: Workspace is closed
body: <p>To create an automatic project I created a plug-in project with the following dependencies:</p>
  
  <ol>
  <li>org.eclipse.core.resources</li>
  <li>org.eclipse.equinox.registry</li>
  <li>org.eclipse.core.runtime</li>
  </ol>
  
  <p>And the following java class located in the src folder:</p>
  
  <pre><code>package tester;
  
  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 void main(String[] args) {
          // TODO Auto-generated method stub
          IProgressMonitor progressMonitor = new NullProgressMonitor();
          IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
          IProject project = root.getProject("DesiredProjectName");
          try {
              project.create(progressMonitor);
              project.open(progressMonitor);
          } catch (CoreException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
  
      }
  
  }
  </code></pre>
  
  <p>After running the plugin, I ran the java class to create a project in eclipse application, but gave the following error:</p>
  
  <pre><code>Exception in thread "main" java.lang.IllegalStateException: Workspace is closed.
      at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:399)
      at tester.tes.main(tes.java:15)
  </code></pre>
  
  <p>What am I doing wrong? And I apologize for my bad English.</p>