Converting a general project to a Java project in Eclipse IDE

If you are not using Eclipse EE then to change a project from a general project to a Java one you will need to edit the project's .project file. This file is located in the root directory of the project.

Before editing the file first close the project or shutdown Eclipse, next open up the .project file in your text editor, it may look like this:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Example Project</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
    </buildSpec>
    <natures>
    </natures>
</projectDescription>

The natures section will need updating to the following:

<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
    <name>Example Project</name>
    <comment></comment>
    <projects>
    </projects>
    <buildSpec>
    </buildSpec>
    <natures>
        <nature>org.eclipse.jdt.core.javanature</nature>
    </natures>
</projectDescription>

Once this file is saved and the project is reopened in Eclipse you will need to edit the project settings to set the correct library path as by default the root directory will be used.

Last updated: 29/08/2013