During the coding of my Bulk Import Plugin, I had the needs to import java projects into a workspace via code. Via Eclipse’s API to be precise. After reading the code of what happens when you import a project, here is the critical bit of code:

Runnable runnable = new Runnable() {
    public void run() {
    try {
        IPath projectDotProjectFile = new Path(pathToMyProjectDir+ "/.project");
            IProjectDescription projectDescription =
            IProject project = workspace.getRoot().
            JavaCapabilityConfigurationPage.createProject(project, projectDescription
                .getLocationURI(), progressMonitor);
        catch(CoreException e) {

// and now get the workbench to do the work
final IWorkbench workbench = PlatformUI.getWorkbench();