Class not found by IntelliJ, found by the compiler

I have a project where a class belonging to zookeeper is not found by IntelliJ. Some packages are found, some are not from the same jar. If I tar tvf the jar, I see the packages. When I build the project, and run it, all is good. However IntelliJ does not show this package, highlights the class in red, and does not display the package when opening the jar. The jar is a regular zookeeper-3.4.5 jar. I have invalidated the caches to no avail. It makes editing extremely difficult. What am I missing? Thanks,

- Bernard

1 comment

It sounds like IDEA is referencing a different version of the zookeeper JAR than what the compiler is referencing. When you say you can build and run the code, is that via the IDEA internal build or via a build tool like ant, maven or gradle (even if launched from IDEA)? I would have to suspect it is the latter. This would be a case that IDEA and the build tool are somehow referencing different JARs. If the former (i.e. you can build via IDEA's internal make), invalidating caches would be the fix (which you indicate has not worked). I can't see any way that IDEA would have the reference for compiling, but not for editing / inspections. My only recommendation is triple and quadrupedal check your project settings and the library settings. Also make sure there are not two definitions for the same jar (i.e. an old version and a new version). If that fails, try creating a new project. Something might just be corrupt in the settings file(s).


Please sign in to leave a comment.