简体   繁体   中英

Eclipse does not refresh project files in package explorer view

Today I see a strange behaviour of Eclipse 3.5.2 for the first time in 3 months.

First, when I run a main function, it runs a previously compiled version. Let's say I press Ctrl+F11 in the window with an open java class and existing main function. Usually it rebuilds the class and runs a new version. Today even if there was a compile mistake, it would run fine. So I guess it does not recompile the class.

Next, more strangely, if I intentionally make a mistake in the code and Eclipse underlines those lines in red, still the project Explorer does not mark them as containing errors. They remain of grey color if there were not any errors.

First I did not know how to solve this problem. I tried to reopen the project, restart Eclipse and finally reboot the OS. After the tenth attempt, after rebooting, Eclipse said that all project's files are "OUT OF SYNC with the file system". When I pressed "Refresh" - F5 on a project's header name in Project Explorer it finally marked all the files with errors as containing errors and running the main function gave the desired result.

An hour of my work passed and this , with the other project.在另一个项目上。 All the same. No marking of files as red, running no matter what old version of class with no compile errors.

And since Eclipse does not tell that files are out of sync, simply pressing F5 on a project cannot help.

What can you suggest?

When you select a project in the Project Explorer view and press F5, Eclipse should traverse the entire directory tree for the project checking that all files and directories all in sync. It does for me ...

The only thing I can think of that would cause this not to work is if you have file system timestamp anomalies. For example, if a file in the file system is updated but the file's last-modified shows that it was updated in the past. This kind of thing can happen if your machine's system clock is moved backwards or forwards at an inconvenient time. If you think this might have happened, try closing all projects, restarting Eclipse and doing another F5 refresh.

(I run into Eclipse synchronization issues a lot, but I put it down to a combination of flakey plugins and doing builds from the command line. Either F5 or Project>Clean usually works for me.)

Is Build automatically on? ( Menu > Project > Build automatically )

It happened to me because there was a cyclic dependency between two projects. Each project had the other on its build path.

Solution : Reimport the project

It happened to me when checking out a new file from svn in explorer. Eclipse could not find the new file for some reason.

I tried refreshing the project( F5 ) and Project > Clean and build the project( Project > Build All ) none of these worked for me.

So I deleted the project from the Project Explorer view(Not from hard disk). Make sure you unselect " Delete project contents on disk(cannot be undone) " checkbox and save any unsaved changes before you do this.

Now reimport the project using File > Import option. That should work in most cases.

If you use gradle, or something similar, instead of reimporting a project you can just regenerate the project files ( gradle eclipse for example), and then you can refresh the project. Less cumbersome than deleting and reimporting.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM