Convert Eclipse project type from general to Java [duplicate]
Asked Answered
P

2

29

I'm taking over another team's project and am experiencing some bizarre Eclipse issues.

I'm using Subversive as my plugin, and when I go to check the trunk out it brings me to a standard "Check Out As" dialog where it allows me to select the check out method, and the only one that works for me (or is applicable) is the last option (Check out as a project with the name specified).

So I specify the name, and the project then checks out as normal and all is well, except...

Although this is supposed to be a Java project (WARs up into a Java web app), it seems that the team that made the project created it as a general project (by going to Project > Properties > Resource > Type = 'Project').

As such, none of the typical features that come with a Java project are enabled, including (but certainly not limited to):

  • F3 doesn't work, even if the type is defined inside the same package (folder in this case) as the type I'm currently editing (because Eclipse isn't treating this like a Java project)
  • Can't search for Java classes
  • Can't build from inside Eclipse (because there are not source packages, only folders), etc.
  • This list goes on and on...

So my question(s) are:

  • Is there a way to convert this General Project type into a Java Project without having to make a whole new project and copying everything over?
  • I'm wondering if I checked the project out incorrectly, but none of the checkout methods (in Subversive) were really applicable: (1) Check out as a project configured using the New Project Wizard (why check out as a new project?!?), (2) Find projects in the children of the selected resource (no), (3) Check out as a folder into an existing project (no).
  • Is there any other avenue I could take here to "Java-ify" this project?
Puri answered 6/3, 2012 at 21:18 Comment(2)
See also How to change an Eclipse default project into a Java projectDishevel
The answers below are insufficient to get the project to build and run as normal. See the link by @Dishevel for a more complete answer. ( e.g. specifying the usage of 'org.eclipse.jdt.core.javabuilder ' )Secund
C
46

Under Project Properties -> Project Facets -> Convert to faceted form... you can select Java - this will add the Java functionalities to your project. There you can also add other facets like Dynamic Web Module if necessary.

From what you have written the project was checked out correctly. The option Check out as a project configured using the New Project Wizard is applicable when the .project file does not exist in the repository and you have to select the project type manually. It will only create a new Eclipse project locally.

Corticosterone answered 6/3, 2012 at 21:42 Comment(6)
I don' see Project Facets on my eclipseAnethole
Note that "Project Facets" is only available in the Java EE version of Eclipse (or with WTP installed). See Eclipse Bug 102527 for having this functionality in all versions.Distillate
I have WTP installed in my eclipse but I can't find the Project Facets option in the propertiesFrancoise
You should probably update this answer to match modern versions of Eclipse.Dewie
@Luís what do you mean? I have just tested it in the current version of Eclipse (4.6) and it still works as I described it.Corticosterone
Right . Works in the latest 4.7 version exactly as described above.Heber
C
21

Partial response: you can convert your project to a Java project by adding the following nature to the .project file contained at the root of your project:

<natures>
    <nature>org.eclipse.jdt.core.javanature</nature>
 </natures>

And I think that the purpose of the Checkout as New project is to be able to create an "Eclipse project" for a project that has no .project and .classpath file. This allows you, for example, to say that the project is actually a Java project.

Chasteen answered 6/3, 2012 at 21:22 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.