Why can't eclipse resolve class in same package?

后端 未结 17 1831
逝去的感伤
逝去的感伤 2021-01-31 15:56

I hit F5 ~1000 times and restarted eclipse (also with -clean), deleted /bin, but nothing helps. Manually importing DoodleClient does not help. DoodleClient exists and is perfect

相关标签:
17条回答
  • 2021-01-31 16:18

    I have 3 projects in my project explorer and they have dependencies on each other.

    They all went nuts and I had 9000+ errors across all 3 projects.

    It turned out that cleaning each of them in the correct order (middle, top, bottom) resolved everything.

    Cleaning in the correct order is what fixed my issue.

    Just thought it was worth mentioning :)

    0 讨论(0)
  • 2021-01-31 16:20

    Right click on project then R-click on Maven then Update Project

    0 讨论(0)
  • 2021-01-31 16:20

    I had the same problem. I tried to add the statement with the static method call again and delete the old one. Eclipse even helped me with auto-completion and after that it underlined the statement again. In my case closing the project and importing it again after that worked.

    0 讨论(0)
  • 2021-01-31 16:21

    Luckily I didn't have 1000's of errors; for my 20+ class resolution problems, what I did was to:

    1. Delete a part of the name of the offending class
    2. Place cursor at the end (of remaining fragment of class' name), do an auto-suggest (Ctrl+space) and choose the correct class from the suggestions
    3. Save

    Tedious but it worked....

    0 讨论(0)
  • 2021-01-31 16:23

    Compiler checks dependencies on compiled files, not on source code. So it means the compiler doesn't file DoodleClient.class. To check if you have the compiled class, open the Navigator view (Window -> Show View -> Navigator) and look for the directory that contains the .class files (usually bin/<project> or target/classes for Maven) and check if you have there DoodleClient.class file. If you don't you can:

    1. check the .classpath file to see if DoodleClient.java appears in some excluding attribute in some classpathentry (delete it from the exclusion attribute if it does)
    2. if you are using Maven check if DoodleClient.java appears in an <exclude></exclude> tag in the pom.xml
    3. copy the necessary java files/packages to some other folder on your disk, compile DoodleClient.java manually from dos console with javac and then copy DoodleClient.class in your class folder in your project. Hope this helps.
    0 讨论(0)
  • 2021-01-31 16:23

    None of the things above worked.

    However I could fix it like this:

    1. Installed a new Eclipse Version
    2. Opened a new workspace
    3. Cloned my Maven projects from my Git repo into the new workspace
    4. Imported them in Eclipse as Maven Projects

    Result: Eclipse finds classes again.

    0 讨论(0)
提交回复
热议问题