37

I inherited a java project and don't have much experience with Eclipse. In the package explorer I can see the outline of the project with all the classes but when I try to edit any of them it says the source code is not found. When I look the source code is where it seems it is supposed to be. I am assuming that in pulling the code out of source control the path must have changed from the original. Is there an easy way to tell the IDE to just connect a code file to a class?

What's really weird is that 'some' of the files in the very same directory are found while others are not. Can't say I think very highly of this IDE so far.

Belmiris
  • 2,741
  • 3
  • 25
  • 29
  • 10
    Have you tried refreshing from within Eclipse? Right click on the project in the Package Explorer view and select Refresh. – Jim Garrison Jul 08 '11 at 15:27
  • Ah, now I can edit the source files! Thanks. It still shows the little warning signs next to the treeview items. – Belmiris Jul 08 '11 at 15:38
  • This question appears to be a duplicate: http://stackoverflow.com/search?q=eclipse+resource+is+out+of+sync+with+filesystem – Anderson Green Jul 04 '12 at 03:26

10 Answers10

98

Right click on the project in the Package Explorer view and select Refresh.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
31

You can have Eclipse do that automatically for you.

Using the latest version, go to Window -> Preferences.

Select General -> Workspace and from there make sure the first and second option are checked:

  • Build automatically
  • Refresh using native hooks or polling

Eclipse Workspace preferences

This is very useful especially if you use Dropbox or something similar (wuala etc) :)

Jmini
  • 9,189
  • 2
  • 55
  • 77
Kounavi
  • 1,090
  • 1
  • 12
  • 24
1

just refreshing isnt always the answer. I had this source issue happen when I had imported two projects with the same context for review and Eclipse made me disambiguate them, forcing a change to the web context of the second. The source for one was linking to the other context's source folder. eg

  • project A(in folder A1) deployed as /A
  • project A(in folder A2) deployed as /A also but was forced to be /A[later**] upon import

in .settings/org.eclipse.wst.common.component (within folder A1) the wb-module element referred to the other context /A[later] and was using its source code, not that for /A.

I solved this by updating all references in the org.eclipse.wst.common.component file in each project to suit their correct project

** the suffix I chose upon import, it has no particular significance

bigbadmouse
  • 216
  • 1
  • 11
0
  1. Right click on the project in the Package Explorer view and select Refresh. If it is not working,
  2. Clean the project... project menu -> clean... and refresh
Vinoj John Hosan
  • 6,448
  • 2
  • 41
  • 37
0

Click on the project, then press F5 to refresh the file. It should be fine.

0

If refresh and clean doesn't work, it might work to just simply just run your code. For me it did the trick. After many refresh and cleaning/ building didn't work.

Riverside
  • 207
  • 1
  • 12
0

Just remove all projects from eclipse workspace and Re-Import the all projects again. It is working for me. Just try it

Ganesa Vijayakumar
  • 2,422
  • 5
  • 28
  • 41
0

If using maven or other builder be sure that you disable the plug ins some plug ins, specially the ones meant to generate/change code will never let you be fully on sync

Ordiel
  • 2,442
  • 3
  • 36
  • 52
0

By default, 'F5' on a highlighted resource will also refresh it.

bvulaj
  • 5,023
  • 5
  • 31
  • 45
0

You can right click on the project name and click refresh. And just to be sure, you can select the package name and right click 'Refresh' too.

Basanth Roy
  • 6,272
  • 5
  • 25
  • 25