41

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 perfectly fine, everything worked before. Clicking on "Import 'DoodleClient' ..." does nothing.

What I did before this problem occured:

  1. I added *.class to .gitignore
  2. git rm *.class
  3. On the next pull, hunderts of .class files were deleted by git

enter image description here

Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89

17 Answers17

89

Alternatively, you can highlight the project :

Choose Clean ... from Project menu and if you have activated the Build Automatically option (in the same menu), the classes will be generated anew.

Stephan
  • 41,764
  • 65
  • 238
  • 329
samorai
  • 899
  • 1
  • 6
  • 4
  • 11
    Tried this, did not help at all. – matt5784 Dec 03 '13 at 22:51
  • 1
    This worked for me. But, what does this clean do and why doesn't eclipse clean automatically ? – Erran Morad May 15 '14 at 22:00
  • This only worked once I closed all of the open files in eclipse, then re-tried. Prior to doing this it would not work. I don't know if this was the actual reason as I'd also attempted every other solution in this question. Worth a shot though if you're not having any luck. – r1chjc Aug 27 '15 at 09:14
  • Worked like a charm, I had the same problem with SVN. It seems the build path gets messed up. – 8bitAlex Aug 10 '16 at 18:34
28

I could resolve it: On another project (from the same git repo), I had the same issue on several files in different packages. All I had to do was writing a white-space into the file, remove it again and save, so eclipse would re-compile it (I guess).

Some kind of a strange behaviour... :S

Cedric Reichenbach
  • 8,970
  • 6
  • 54
  • 89
  • It may happened if you somehow delete the compiled .class under \target\classes in file system. By editing the .java and save will re-compile the .java and re-generate .class, then fix your problem. – yorkw Jul 30 '12 at 04:08
  • The solution as that given by @samorai. You just rebuild your project (recompile). – Hunsu Feb 01 '15 at 07:31
  • This worked for me when (I think) Maven had a failed build so it cleaned some of the compiled classes and didn't rebuild them. – Derek Sep 27 '17 at 14:24
15

I got the same error in Maven project. Running Maven Clean and closing the project and reopening didn't work for me. Right click project -> Maven -> Update Project worked for me.

Dakshila Kamalsooriya
  • 1,391
  • 4
  • 17
  • 36
8

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

Meena
  • 91
  • 1
  • 2
6

I tried to refresh the workspace (F5) and clean the project, but that did not do the trick. What worked for me was to right-click on the project and select 'Close Project'.

Once closed I re-opened the project. This seemed to refresh all the files for the project in Eclipse.

ScottyG
  • 3,204
  • 3
  • 32
  • 42
5

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....

Isaac Riley
  • 290
  • 4
  • 5
2

The first thing I would do is create a new class in the same package and check if it is visible from this class where you have the issue.

Also I'm not sure but you could check to change the name of your class "D" for something different.

and ...Check if the file actually does exist

Snake Sanders
  • 2,641
  • 2
  • 31
  • 42
2

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.

egelev
  • 1,175
  • 2
  • 11
  • 27
  • I found that Project->Clean…, `mvn clean`, followed by closing Eclipse and starting it up again cleared the error. (I think it's _actually_ caused by a classloader getting stuck; Eclipse does nasty things with them and sometimes it goes wrong.) – Donal Fellows Jun 12 '14 at 14:59
2

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 :)

thonnor
  • 1,206
  • 2
  • 14
  • 28
2

I have the same issue every day, and the solution is different every time. :) You can try something like these:

  • Project menu - Clean
  • Project - Maven - Update project (Alt+F5)
  • Project - Refresh
  • Project - Run as - Maven clean
  • Project - Run as - Maven install
  • Restart Eclipse
  • Remove application from servlet container (if it is web app)
  • Pray.. :)
Laszlo Lugosi
  • 3,669
  • 1
  • 21
  • 17
1

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.
Luke
  • 1,633
  • 3
  • 23
  • 37
1

I've had the same problem with my Java project in eclipse. mvn clean-ing the project did not help strangely. I had to edit the supposedly "missing" class, save it, then clean and rebuild the project. That fixed the issue.

David P
  • 11
  • 1
1

Right click on project-> Build Path ->Configure Build Path->Java Build Path -> then Fix issues in JRE System Library

Nufail Achath
  • 58
  • 1
  • 7
0

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.

kiltek
  • 3,183
  • 6
  • 47
  • 70
0

In my case, the DoodleClient class had all its lines commented. It is not the way i wrote the class, it was a side effect of solving improperly a SVN conflict. So if you just ran an update on your project, you might perhaps want to check again the contents of your file.

Newton fan 01
  • 484
  • 5
  • 14
0

Tried many of the suggestions above w/o success (Eclipse restart, Clean multiple times, auto-suggest etc.). What got me out of this bind was a hard reset to a prior commit (I'm using git), building (this time w/ success), then pulling the latest sources of the project again and rebuilding.

elder elder
  • 645
  • 1
  • 9
  • 23
0

In my case it was that my Java Build Path -> Source didn't had checked the Contains test sources on my include source path and my code was JUnit

Anton Krug
  • 1,555
  • 2
  • 19
  • 32