score:127

Accepted answer

open the .project file and add java nature and builders.

<projectdescription>
    <buildspec>
        <buildcommand>
            <name>org.eclipse.jdt.core.javabuilder</name>
            <arguments>
            </arguments>
        </buildcommand>
    </buildspec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectdescription>

and in .classpath, reference the java libs:

<classpath>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.jre_container"/>
</classpath>

score:1

  1. right click on project
  2. configure -> 'convert to faceted form'
  3. you will get a popup, select 'java' in 'project facet' column.
  4. press apply and ok.

score:1

depending on the eclipse in question the required wtp packages may be found with different names. for example in eclipse luna i found it easiest to search with "tools" and choose one that mentioned tools for java ee development. that added the project facet functionality. searching with "wtp" wasn't of much help.

score:3

another possible way is to delete the project from eclipse (but don't delete the project contents from disk!) and then use the new java project wizard to create a project in-place. that wizard will detect the java code and set up build paths automatically.

score:6

you can do it directly from eclipse using the navigator view (window -> show view -> navigator). in the navigator view select the project and open it so that you can see the file .project. right click -> open. you will get a xml editor view. edit the content of the node natures and insert a new child nature with org.eclipse.jdt.core.javanature as content. save.

now create a file .classpath, it will open in the xml editor. add a node named classpath, add a child named classpathentry with the attributes kind with content con and another one named path and content org.eclipse.jdt.launching.jre_container. save-

much easier: copy the files .project and .classpath from an existing java project and edit the node result name to the name of this project. maybe you have to refresh the project (f5).

you'll get the same result as with the solution of chris marasti-georg.

edit

enter image description here

score:11

joe's approach is actually the most effective means that i have found for doing this conversation. to elaborate a little bit more on it, you should right click on the project in the package explorer in eclipse and then select to delete it without removing directory or its contents. next, you select to create a java project (file -> new -> java project) and in the contents part of the new java project dialog box, select 'create project from existing source'.

the advantage this approach is that source folders will be properly identified. i found that mucking around with the .project file can lead to the entire directory being considered a source folder which is not what you want.

score:11

in newer versions of eclipse (i'm using 4.9.0) there is another, possibly easier, methods. as well as project facets, there are now project natures. here the process is simple get the project natures property page up, and then click the add... button. this will come up with possible natures included java nature and eclipse faceted project properties. just add the java nature and ignore the various warning messages and your done.

project nature

this method might be better as you don't have to convert to faceted form first. furthermore java was not offered in the add facet menu.

score:13

using project project facets we can configure characteristics and requirements for projects.

to find project facets on eclipse:

  • step 1: right click on the project and choose properties from the menu.
  • step 2:select project facets option. click on convert to faceted form... enter image description here

  • step 3: we can find all available facets you can select and change their settings. enter image description here

score:23

i deleted the project without removing content. i then created a new java project from an existing resource. pointing at my svn checkout root folder. this worked for me. although, chris' way would have been much quicker. that's good to note for future. thanks!

score:54

in recent versions of eclipse the fix is slightly different...

  1. right click and select project properties
  2. select project facets
  3. if necessary, click "convert to faceted form"
  4. select "java" facet
  5. click ok

score:120

manually changing xml and/or settings is very dangerous in eclipse unless you know exactly what you're doing. in the other case you might end up finding your complete project is screwed. taking a backup is very recommended!

how to do it just using eclipse?

  1. select project.
  2. open the project properties through project -> properties.
  3. go to "targetted runtimes" and add the proper runtime. click apply.
  4. go to "project facets" and select the java facet which has appeared due to step 4. click apply
  5. set your build path.
  6. if it's a maven project, you might want to select the project, click maven -> update project configuration...

that did it for me. and eclipse is configured correctly. hope it'll work for you too.


Related Query

More Query from same tag