Eclipse could not delete error
I'm working on a project with Eclipse and by now everything was fine, but last time I've tried building it, it returned the error,
"The project was not built due to "Could not delete '/Torpedo/bin/bin'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent Torpedo Unknown Java Problem"
And it deleted my bin folder which stores all the images and stuff needed for the program. (Fortunately I had a backup). I've tried googling it and tried every solution I found, but nothing helped, and also most of them suggests to delete the folder by hand, which I can't. What should I do?
I see this semi-regularly on Windows. I think it's a bug or race in Eclipse, maybe a race with a virus checker which doesn't like a delete immediately followed by a write to the same file that was deleted. The fix I use is to use Project -- Clean from the menu bar.
@Ash is right in the comments above that you should not have resources in your output folder. To help avoid that, I always change the name of my output folder from "bin" to something more obvious like "eclipse/classes"
I have this problem semi-regularly, particularly when deploying to Tomcat or such like, under Windows 7. It also happens to me with the command line version of maven as well, so it's not just Eclipse that has this problem.
The root cause is that something is holding onto a file handle. Most of the problems went away when I disabled windows search/indexing on my PC, but the problems sometimes still occur.
To track down what is going on, you need to download Process Explorer (one of the most useful programs that I have ever come across). This allows you to see exactly what is running on your PC, the files it has open, the performance of the processes, how much cpu it's running, the amount of IO it's doing etc. When you have a file that can't be deleted, you can Find->Find Handle or DLL, and enter part of the name, and it gives you who has it open. You don't always catch it in time, but often enough to know the culprit.
What works for me :
- Close Eclipse.
- Go to your
bin
folder and delete all the contents (not the folder itself). - Start Eclipse.
- Clean your project by going to
Project -> Clean
. - Make sure you check
Project -> Build automatically
.