2

How can I create a new Eclipse Project programatically just by calling a method in my Java class or something like that? Here I found a solution, but when I add this code, I get the following error:

IProject cannot be resolved to a type

This is my code:

IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
if (!project.exists()) {
    project.create(monitor);
    project.open(monitor);
}

I found also another answer here, but still the details are not clear for me. Could you please tell me how can I do it perhaps in some easy to follow steps?

Community
  • 1
  • 1
  • I am really not sure, but I think in order to get access to these primitives, you need to start from a new eclipse plugin (new->other->plugin project) – Leo Sep 12 '14 at 14:07
  • possible duplicate of [Programmatically generate an Eclipse project](http://stackoverflow.com/questions/251807/programmatically-generate-an-eclipse-project) – mmmmmm Sep 12 '14 at 14:17
  • You must run this code in an Eclipse plugin, you cannot use an ordinary Java program to do this. – greg-449 Sep 12 '14 at 14:30
  • create an ant task for doing this. run the ant script with the same jre as workspace. – guleryuz Sep 12 '14 at 14:44
  • Thanks for the replays! It seems that I need to create a plugin but there are many details (perhaps they are very obvious!) that are not explained in those links. could you please tell me the steps with some more detail to create a plugin that create a specific project automatically? – user3657203 Sep 18 '14 at 15:12
  • IProject cannot be resolved to a type? – Steve Staple Jan 30 '18 at 14:10

0 Answers0