I have been given a Source Folder (src
) of a Java Project. I have created a .project
file, kept it inside that folder and imported that Project int
Refactor the name of the folder src/main/resource
to src/main/java
.
Right click the project > Build Path > Use Source Folder.
If you imported a project from external source with pom.xml after import, go to Project->Properties->Maven and enable Java EE - This will resolve the error
Recently I met a similar problem. when importing a project without .project, a default empty .project generated without builders. here is an example to make it work.
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
You can add the src
folder to build path by:
src
folder.And you are done. Hope this help.
EDIT: Refer to the Eclipse documentation
I found similar issue and fixed it by correcting .project file. For java project .project file must have below tag within natures
org.eclipse.jdt.core.javanature
Example of complete .project file
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SampleProjectName</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.maven.ide.eclipse.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>oracle.eclipse.tools.weblogic.sharedLibraryFrameworkValidator</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Looks like you created your Java class under src/main/resources instead of src/main/java