最后我找到了指定要创建的项目的位置的代码。这可以通过使用 IProjectDescription 类的 setLocation() 方法来完成,如下所示:
IProgressMonitor progressMonitor = new NullProgressMonitor();
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject project = root.getProject(page1.getProjectName());
IWorkspace w = ResourcesPlugin.getWorkspace();
IProjectDescription desc=w.newProjectDescription(project.getName());
String projectLocation=page1.getProjectLocation();
IPath path1=new Path(projectLocation+"/"+page1.getProjectName());
desc.setLocation(path1);
project.create(desc, progressMonitor);
project.open(progressMonitor);