Eclipse cannot find existing project in build path

Posted by PNS on Stack Overflow See other posts from Stack Overflow or by PNS
Published on 2012-08-31T09:18:02Z Indexed on 2012/08/31 9:38 UTC
Read the original article Hit count: 212

Filed under:
|
|
|

Here is probably one of the idiosyncrasies of Eclipse and its handling of build paths, which cannot be fixed despite all sorts of workarounds tested so far.

The issue relates to a workspace of several projects, each of which compiles into its own JAR.

Dependencies among the projects are resolved by adding the relevant ones to the build path (no Maven or other external tool or plugin is used), via

Project -> Properties -> Java Build Path -> Projects

Among all these projects, a couple (say, com.example.p1 and com.example.p2) refuse to recognize a third (and simple) one (say, com.example.p3), while all other projects do. So, although P3 is added to the build path, all related classes from P3 are imported properly and the source code of each such class is accessible by hitting F3, Eclipse keeps complaining that

The import com.example.p3 cannot be resolved

and

SomeClass cannot be resolved to a type

where com.example.p3.SomeClass is one of the P3 classes.

If instead of the P3 project I put its compiled JAR in the build path, the issue disappears. However, code in P3 changes frequently and it is a time waste to keep compiling and refreshing the workspace so that the change is picked up, not to mention that this should not happen in an IDE anyway (and it does not for the other projects using P3).

Among the workarounds tried are things like:

  • Removing and adding again P1, P2, P3
  • Cleaning up and recompiling everything
  • Checking whether any other project loads the P3 JAR
  • Putting P3 at the top of the Eclipse build path "Order and Export" list
  • Using the "Fix project setup" suggestion of Eclipse (available when hovering the mouse over the red-underlined-error compilation line). Actually, this option offers adding to the build path either P3 or its JAR, but if P3 is added, the issue reappears.

Any ideas?

© Stack Overflow or respective owner

Related posts about java

Related posts about eclipse