Eclipse: Resource not in build path of Java project

I was given the Source Folder ( src ) of the Java Project. I created a .project file, saved it in this folder and imported this project into Eclipse 3.6 using the option “Import existing projects into the workspace” and added the necessary .project files to .project .

Now the problem is that when I make a call hierarchy for the project, it displays an alert window saying: "The resource is not in the build path of the Java project."

Can someone please let me know how to solve this problem?

Please see image here.

enter image description here

thank

+63
java eclipse
Feb 27 '12 at 12:25
source share
12 answers

You can add the src folder to create the path:

  • Choose a Java perspective.
  • Right-click on the src folder.
  • Choose build path> Use source folder.

And you're done. I hope for this help.

EDIT: Refer to the Eclipse documentation

+72
Feb 27 '12 at 12:32
source share

I am trying to set up a dynamic web project using eclipse and its maven plugin. I choose maven-archetype-webapp and face the same problem (which I encounter when trying to automatically create getters and setters for some attributes).

My way around this is to right-click on the project, select Build Path → Configure Build Path, and then remove the weird Exclusion: ** exception filter that I found in the entry / src / main / resources section.

+14
Jan 30 '15 at 14:30
source share

I recently met a similar problem. when importing a project without .project, an empty empty project created without assemblers. 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> 
+11
Feb 16 '15 at 4:43
source share

I found a similar problem and fixed it by fixing the .project file. For a java project, project.project should be below the tag in natures

org.eclipse.jdt.core.javanature




Example of a 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> 
+8
Aug 13 '15 at 5:09
source share

This means that your project is not on the Eclipse compilation path. If, after the problem with the accepted answer persists, you must first transfer this project to the compilation path. To do this, you need to import the project into the workspace again, after which it will work fine.

A similar problem came to me, and I did everything I told you, and it worked for me.

+5
Jun 19 '15 at 8:41
source share

In my case, I had a java project containing many subfolders, each of which contains its own src folder.

 project -subfolder --src/main/java -subfolder2 --src/main/java 

There were no options available when I used the option "Build path →" as described in other answers.

I needed to go to Project -> Properties -> Fac Facets and click convert to faceted project .

Then I got all the src folders added to the build path.

+3
Jul 24 '17 at 9:59
source share

Set the src/main/resource folder name to src/main/java again.

Right-click the project> Build Path> Use Source Folder.

+1
Dec 09 '16 at 18:06
source share

When using Eclipse Oxygen with the multi-module maven project, make sure you are not editing the file in the parent maven project .

This led to the Open Announcement, Open Type Hierarchy, and Open Call Hierarchy displaying the scary dialog in question. This might even interfere with autocomplete.

+1
Apr 25 '18 at 14:01
source share

All you have to do is move the Project folder under Src, that's all. Let me know if you have more questions.

0
Mar 19 '15 at 21:07
source share

It looks like you created your Java class under src / main / resources instead of src / main / java

0
Aug 16 '16 at 15:40
source share

If you imported the project from an external source using pom.xml after importing, go to Project-> Properties-> Maven and enable Java EE - this will fix the error

0
Mar 17 '18 at 0:48
source share
  1. Delete a project from the workspace (uncheck the box for physically deleting a project from disk)
  2. go to the project location and delete the .project file
  3. Import the project again.
0
Jun. 19 '19 at 6:54
source share



All Articles