Query, while creating a jar? - eclipse

Resource is out of sync with the file system
This the error that is thrown out while creating a jar in eclipse IDE...
What does this mean? And how to rectify it?...

I'm assuming this is while you're using Eclipse...
I suspect that it means you've changed a file on the file system but the Eclipse workspace is still "looking at" the old version. Hitting Refresh (F5) on either the file or the whole project would usually sort it out. If you're seeing it every time you create a jar file, that suggests your project is looking at your build output, which isn't ideal.

Eclipse caches file content to make things go faster.
It has detected that the version on disk has changed since it was put in the cache, and you need to refresh the workspace to update the cached version.
This typically happen when you fiddle with files outside of Eclipse. If the process doing the fiddling is invoked from within Eclipse you can tell Eclipse to refresh the workspace when the process is finished.

Eclipse keeps metadata about all files within every eclipse project. "Resource is out of sync with the file system..." means that eclipse has noticed that a file has been changed (or deleted) from outside eclipse. Refreshing the project in question (from the context menu in the package explorer) should fix the problem.

Related

Eclipse crashed and deleted all my work

Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
Is it possible to force Eclipse or JVM to use trash can, so that if it goes mad and delete everything, files could restored.
UPDATE
Files were definitely wiped out. This was checked with third party file managers. Also entire disc were searched for traces.
Some good news is that Eclipse history remained. This allowed to restore some files I changed from Eclipse. But this project was consisting of multiple other files, that were written not by me (taken from other libraries) or contained some data I was editing not in Eclipse (like XML or raw data).
All these files were wiped out by Eclipse.
If this would not happen to me I would also say it is unlikely. But it has happened.
The problem is somehow related with
(1) Eclipse
(2) Maven (m2e)
(3) Eclipse RCP
(4) Tycho
At some moment Eclipse started to show numerous error windows and I was to kill the process. After that I found files absent.
So I need some extra protection layer.
UPDATE 2
Crash repeated. This is a message during file wiping out:
This time I was not using Maven and Tycho.
UPDATE 3
Third crash.
Crash occurs only after error Application ... could not be found in the registry, which itself buggie.
UPDATE 4
Still unable to reproduce situation from scratch...
UPDATE: I think from this question you were working on an Eclipse RCP plugin or something like that when this happened.
So you probably broke your Eclipse in some fashion. Do not trust anything Eclipse tells you at this point! Look at the actual filesystem!
Eclipse crashed and deleted all project files, including written by me and XML files from another program which were not related to Eclipse.
That's highly unlikely. (Especially if those XML files were not in the workspace. But even if they were, it's very unlikely.) You probably opened a new workspace without realising it, or maybe Eclipse has some bug where it won't show you files that are actually there. Or maybe you accidentally switched to the wrong view (in Java the normal view for files is Package Explorer, if I remember correctly).
Or maybe you were storing your workspace on a USB stick (aka pen drive) or network drive and you accidentally disconnected from it without realising it.
Check in the workspace (the actual workspace you were using at the time, not the workspace you are now using, which, as I said, might not be the same thing), using Windows Explorer (if you are using Windows) or Finder (if you are using a Mac) or using ls (if you are using something else). Are the files really gone?
This Was My Fault
I was setting up a workspace location pointing to project folder and also setting clear workspace checkbox.
::shame::

Eclipse: The project was not built since the source file ... could not be read

When compiling my Java project, I get this error in Other errors:
Description Resource Path Location Type
The project was not built since the source file /PROJECT/src/main/org/../ABC.java could not be read PROJECT Unknown Java Problem
Indeed, the file is listed in Package Explorer but shows only "Error retrieving content description. On the file system, the silent dir exists but not the file; git status is missing nothing. How do I resolve that compile error?
Simply restart eclipse, refresh all projects and do a clean build. That should fix it. Don't forget the eclipse restart, else no matter how many times you do a clean build or refresh, it will not fix the problem
Looks like someone has deleted that file but eclipse still think that file is part of the project. Might have happened when someone deleted a file from the source control in an improper way.
If you dont have pending changes then you can get fresh copy of the project and import it into your workspace.
If you have pending changes then take a copy of changes and repeat above step. ( A restart of eclipse may be necessary)
It can be related to missing location
Select File => properties => Resource => Edit file location.
I know the answer is accepted but in my case that solution didn't work for me, I had restored files from a backup to my local project in linux and the files I restored were owned by root with only the owner being able to read/write the files. SO, I sudo chowned the files "sudo chown _R myUser:myUser *" at the base of my project, refreshed in Eclipse (f5) and the annoying repeated failure of my build was a thing of the past.
If you are writing Maven projects, try right click on the project and select [Maven] -> [Update Project...]
It works for me.
For me there was a different solution than mentioned here.
I was doing a no-no, I imported a project that had a .project file, and there was some errors in the way my version of eclipse was reading some of the files. The package names and files had a little ! symbol with a yellow background.
The solution was to delete the packages. Obviously make a backup. But in doing this most times the files nor the packages were deleted. Instead eclipse refreshed and the desired files were there. Sometimes I had to hit refresh (F5), and sometimes I had to restore files.
I found it best to delete the packages as that is where eclipse was having reading the data.
If the missing file is still mentioned in the Linked Resources, no refresh and restart of Eclipse will ever solve the problem. You have to delete the file in the Project Properties Linked Resources list.
For anyone using VS Code with the RedHat Java plugins (which use Eclipse tooling under the hood), I got this error as well. I fixed with the following:
# Quit VS Code
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage/*
# Reopen VS Code
As all others said, it is most probably an issue with the internal caches of Eclipse.
I usually restart the IDE with the additional -clean option to wipe out the OSGi-related caches, then clean and rebuild all the projects.
If the problem persists, I realized that cleaning up the single affecting project works better that cleaning up the whole workspace. (Ominous... XD)
This usually happens to me when merging changes that imply renaming or deletion of source files, prior to launching Eclipse.

Does refreshing in Eclipse also Clean the project?

I hope the question isn't too vague but I was wondering if running 'Refresh' also calls 'Clean'.
Does running 'Clean' run 'Refresh' ?
Nope, it does not. Refresh reloads the last version of your project's files (like, if you modified something outside of eclipse, you need to refresh in eclipse to have the new modif show up). Clean on the other hand deletes all the compiled files and recompiles your project's sources
No, it doesn't. Eclipse reads the files from the file system and buffers them. Refresh only tells eclipse to reread the files.

Eclipse hangs while opening workspace after upgrading to GWT 2.0/Google app engine 1.2.8

After upgrading to the newest GWT/Google app engine I have problems opening my workspace in Eclipse. On startup, Eclipse hangs almost immediately and needs to be closed. This happens only in the workspace where I use GWT with app engine, and I weren't able to consistently reproduce it - sometimes it starts normally, and sometimes I need to kill the proces and restart it. There is nothing in Eclipse error log. Eclipse version is Galileo, running on Windows 7 RC.
Anyone else had similar problems? I googled but Google is not my friend today.
EDIT: Still happens after upgrading to GWT 2.0.1.
I got frustrated with not being able to open my workspace today, and finally solved this by importing projects into a new clean workspace.
Create new workspace and open it in Eclipse (to create .metadata folder).
Close Eclipse.
Manually copy all settings from old workspace (the most important settings are stored in the .metadata/.plugins/org.eclipse.core.runtime/.settings directory). Alternatively, you could use File / Export / General / Preferences in Eclipse, and then File / Import them, but I wasn't able to open workspace to do that.
Open the new workspace.
File / Import / General / Existing projects into workspace. Select root folder of your old workspace, and take care to check "Copy project into workspace".
Restart Eclipse and check that everything in the new workspace is working as it should.
Delete your old workspace.
EDIT: Another, and a bit better workaround which apparently works:
Close Eclipse.
Temporary move offending project somewhere out of the workspace.
Start Eclipse, wait for workspace to load (it should).
Close Eclipse again.
Move the project back to workspace.
I used "eclipse -refresh". Apparently it hangs on refresh something, the lower right corner tells you, what it's doing. For me it was refreshing the gwt runtime in a specific project, maybe trying to find an update or something. If you don't want to reimport your whole workspace, try -refresh or move this project temporarily out of the way.
I just deleted the state.dat file in the GWT project metadata, which seemed to remove the blocking and then triggered a recompilation.
<workspace>/.metadata/.plugins/org.eclipse.core.resources/.projects/<GWT project>/org.eclipse.jdt.core/state.dat
This probably won't serve as a general solution, but it worked for me and it's a lot quicker than having to copy whole projects. Maybe another file will have the same effect. I think the trick is just to "damage" the GWT project metadata enough to have it rebuilt.

Can't save project preferences in Eclipse

All I am trying to do is to set the Java compiler for my project as 5.0. It is 1.4 by default. When I try to save by pressing OK button I get the following error.
Preferences Save Failed:
Reason:
Exception Occured while saving project preferences:
/com.myproj.reqmanager.ui/.settings/org.eclipse.jdt.ui.prefs.
I never got this error earlier. I mean I have imported this project before and saved preference settings without any problem. Out of nowhere I am getting this problem now.
Like Liam I store my project on Dropbox and use it on two different machines and also got the same error. A simple refresh (select the project and press F5, or rightclick on the project and choose Refresh) did the trick for me, as the resource was out of sync. This is usually displayed (e.g. in the editor when trying to edit a source file), but in the case of preferences you'll have to find that message in eclipse's log:
!MESSAGE Exception occurred while saving project preferences: /Utils/.settings/org.eclipse.jdt.core.prefs.
!STACK 1
org.eclipse.core.internal.resources.ResourceException: Resource is out of sync with the file system: '/Utils/.settings/org.eclipse.jdt.core.prefs'.
This might actually be the issue for both of you, as any external modification to a project will cause this out of sync error, and creating a new workspace or using another eclipse version likely purges eclipse's cache, resulting in an automatic refresh.
If you follow this thread, this can be:
because of the use of Eclipse with a workspace on a network drive (not necessarily your case, but worth mentioning just in case)
because the file is somehow locked (either by another process or by a Version Control System with pessimistic locking). See also bug 130266:
Read-only project files come up a lot when dealing with source control systems (like Perforce) that make the local files read-only until they are "checked out".
Five years later and this still occurs. In my case I moved the .settings folder, saved again (.settings is created automatically) and merged the files manually.
Happens on Android Developer Tools Build: v22.6.2.
Check the project's Properties -> Java Compiler, and make sure the 'Compiler compliance level' is 1.8 or 1.7 instead of 1.4.
If this still fails to remove the error, deleting the .settings folder certainly works.
I had this problem also. I had used two versions of eclipse, one on my home machine (juno) and one on my work machine (indigo). Both shared the same folder using a Dropbox folder. All worked fine until I wanted to make some editor style changes, the settings would not save.
The solution in my case was to update the indigo version to juno on my work machine.
Delete the eclipse project files:
.settings (directory)
.project
.classpath
File -> Import... -> Maven -> Existing Maven Projects