I am getting resource not on the buildpath of the project
I just hit this problem myself, and it's baffling. You get it in a bunch of different places as you try and treat a Java file as, you know, a Java file but Eclipse hasn't figured out that it's actually a class within your project. The reason it doesn't know (or the reason it didn't know in my case) was because the directory hasn't been marked as a source directory for the project. So you need to tell the project configuration that the file is in a directory that holds source files. Here's how:
Open your project's properties.
Under "Java Build Path", click on the "Source" tab.
Click "Add Folder..."
Find the folder where you have the unrecognized java file. (In my
case it was test->Java)Put a check by the folder. (I put it only by "java" and not by
"test" given that the test folder holds a lot of other stuff.)Click ok, click OK again, perhaps refresh, and you should be good to
go.
Understanding Eclipses' "The resource is not on the build path of a Java project" error message?
Refactoring operations, like many other java-specific operations, rely on the ability of the tooling to correctly parse the code in question. Generally, that means that:
- The code has to be valid enough (syntax and grammar) for the selected element to the correctly parsed.
- The java source file in question needs to be within a java project's source folder.
- The build path must be correct and error free so that referenced classes and packages can be correctly identified.
This message is telling you that one or more of those conditions are not met.
Why does my eclipse project not have a build path?
It looks like you did not add Eclipse project metadata files to your source control system, so Eclipse doesn't know what your build path is or whether it is even a java project. You can see that the little folder on your dungeonworld project is missing the little 'j', which means Eclipse doesn't think it's a java project.
Go back to your other computer and look for the following files in your original project root...
- .project
- .classpath
- .settings/*
Make sure all of the end up in your source control system or nothing will work right.
Related Topics
Eclipse Console Not Showing Output
How to Go About Adding an Image into a Java Project With Eclipse
How to Avoid Nullpointerexception With an Empty Cell Using Poi
Jackson Jsonmappingexception: Can Not Deserialize Instance
How to Clean Old Dependencies from Maven Repositories
How to Remove Trailing Zeros from a Double
Maven Build Cannot Find Symbol When Accessing Project Lombok Annotated Methods,
Regular Expression for Excluding Special Characters
Use String.Split() With Multiple Delimiters
How to Download Entire Folder Located on S3 Bucket
Null Can Not Be Compared to Double - Why
Check and Open Downloaded File in Selenium
The Request Was Rejected Because No Multipart Boundary Was Found in Springboot
How to Quickly Check If Url Server Is Available
Add Secure Flag to Jsessionid Cookie in Spring Automatically
Print Array Without Brackets and Commas
What Is the Most Elegant Way to Check If All Values in a Boolean Array Are True