Reputation: 32321
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 into Eclipse 3.6 through the Import Existing Projects into Workspace Option and added the required jars to it.
Now the problem is that when ever I do a Call Hierarchy on a Project, it displays an alert box saying "The resource is not on the build path of a java project"
Could somebody please let me know how to resolve this?
Please see the image here:
Thanks
Upvotes: 86
Views: 259685
Reputation: 41
Right click on your project -> Properties -> Project facets -> Convert -> Select Java in the checkboxes -> Apply and Close
Now you should be able to see your hierarchy.
Upvotes: 3
Reputation: 478
It means your project isn't on the compilation path of Eclipse. If after the accepted answer the problem still persists, then you need to first place that project on the compilation path.
For that, you need to import the project again into your workspace.
Upvotes: 7
Reputation: 438
I found a similar issue and fixed it by correcting the .project
file. For a Java project the .project
file must have the below tag within the natures
tag
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>
Upvotes: 7
Reputation: 19312
I am trying to set up a dynamic web project using Eclipse and its Maven plugin. I am selecting maven-archetype-webapp and am facing the same problem (which I run into when trying to automatically produce getters and setters for some attributes).
My way around this was to right-click on the project, select Build Path --> Configure Build Path and then remove a weird exclusion filter "Excluded:**" which I found under the entry /src/main/resources.
Upvotes: 19
Reputation: 1010
Seems you imported the project to your workspace from git and not from a local repository. To add a local repository project to the workspace do the following:
Click on project (demoApp) -> imports projects -> finish.
Upvotes: 0
Reputation: 876
Recently I met a similar problem. When importing a project without a .project
file, a default empty .project
file was generated without builders. Here is an example .project
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>
Upvotes: 15
Reputation: 1
If you open a file while in a perspective other than Java on a new project that hasn't yet been built and then go back to the Java perspective, you can get this alert message. Close the file and open it back up while in the Java perspective and then retry. Then if that fails the other solutions already provided will be of help.
For example:
Upvotes: 0
Reputation: 11035
Using Eclipse Oxygen with a multimodule maven project make sure you're not editing the file in the maven parent project.
This caused the "Open Declaration', 'Open Type Hierarchy' and 'Open Call Hierarchy' to show the dreaded dialog in question. It would even mess with the autocomplete.
Make sure you are not editing the parent project and instead edit the child project to avoid the error.
Upvotes: 3
Reputation: 3470
In my case the source folder wasn't specified correctly. To solve the problem :
Properties
Java Build Path
Source
tab and inspect what is there. Make sure to Add Folder...
and select the folder which is the root of your source files.As a result, you will notice that your folder structure in the project explorer will be modified to display package icons and package names instead.
Upvotes: 1
Reputation: 51
Upvotes: 4
Reputation: 75
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
Upvotes: 0
Reputation: 1593
In my case, I had a java project containing many subfolders, each containing its own src
folder.
project
-subfolder
--src/main/java
-subfolder2
--src/main/java
There was no options available when I used the Build Path -> right click option, as outlined by other responses.
I had to go to Project -> Properties -> Project Facets and click convert to faceted project
.
Then I got all the src
folders added to the build path.
Upvotes: 13
Reputation: 21
Refactor the name of the folder src/main/resource
to src/main/java
.
Right click the project > Build Path > Use Source Folder.
Upvotes: 2
Reputation: 849
Looks like you created your Java class under src/main/resources instead of src/main/java
Upvotes: 0
Reputation: 33
All you got to do is move your Project folder under the Src, that is all, it is done. Let me know if any more questions.
Upvotes: 0
Reputation: 6278
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
Upvotes: 96