Eclipse could not delete error

JavaEclipseBuild

Java Problem Overview


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?

Java Solutions


Solution 1 - Java

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"

Solution 2 - Java

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.

enter image description here

Solution 3 - Java

What works for me :

  1. Close Eclipse.
  2. Go to your bin folder and delete all the contents (not the folder itself).
  3. Start Eclipse.
  4. Clean your project by going to Project -> Clean.
  5. Make sure you check Project -> Build automatically.

Solution 4 - Java

It is a Windows 7 problem. We generate a lot of code here and face the same problem when generating code [two-step:

  1. XSL transformation and
  2. pretty-printing], one of the Windows processes, probably Explorer.exe, intervenes. This only happens one time out of 200.

On Linux and Windows XP, we neither have the problems in Eclipse nor generating files.

And we do face the problems even if running code generation and Eclipse as administratör.

We've asked Microsoft for support, but the suggestion we've had so far is "Reboot!". Hopeless!

Solution 5 - Java

Problems with deleting things for me under Windows usually come down to one of two things:

  • The file being open by a program. This includes the JVM. This usually doesn't go away by itself.
  • The Antivirus-program on the computer has the file open for whatever it needs to do. This usually goes away after a while. I frequently recreate workspaces, and if this happens too fast, Eclipse complains that it cannot delete files.

Solution 6 - Java

Check if any other process is using a file within the target "bin" folder, and kill it. Typically this happens with other Java processes invoked from Eclipse.

Solution 7 - Java

I had a similar problem with windows XP/Vista. In my case the total length of the file was more then 255 characters long.

/abcd/abcd/abcd/abcd..../abcd

The only solution I found was to rename the directories to make it shorter then 255 characters.

/a/a/a/a/a/a/a.../a

After that you can delete it. It is a restriction in the windows API. The file system can manage more then 255 characters but not the explorer which uses the windows api.

Solution 8 - Java

I just had this problem and it was TGitCache.exe locking the bin folder. If you use TortoiseGit, just kill the TGitCache.exe process and you should be all set.

Solution 9 - Java

I just had this issue ... and it was due to the fact that I had a command line session (DOS screen...) open in a folder in the BIN tree for the project I was building ... I wanted to run the .class file via command line.

Solution was simply to cd back to the bin folder so that the "clean" could remove and recreate those target folders.

Solution 10 - Java

This just happened to me. I had User Access Control (UAC) turned off when it happened (windows vista 32 bit). I turned UAC back on, rebooted vista and then the error went away. Counter intuitive that with UAC turned off, delete of the bin/net directory fails, but with UAC back on it works. Go figure.

Solution 11 - Java

The process I followed is

  1. Close eclipse
  2. Explore to the folder
  3. Delete it

Solution 12 - Java

I have been having this problem quite a bit recently. I realised it started happening after I set the workspace to automatically reload all resources from disk. This can be configured from the menu: Preferences > General > Workspace.

Solution 13 - Java

I was working on an open source project, and this particular problem was a real pain in the ass and ended up wasting 4 hours.

What eclipse is trying to say is:

I do not have access rights to the particular bin folder. If you are using linux, then:

  1. Open your terminal
  2. Go to the directory where from you are importing the project to eclipse and chmod 777 -R project_folder
  3. Check again, if the problem still persists, go to the folder within your project where bin is located and do the same thing - chmod 777 -R bin_folder
  4. Now open eclipse, clean and build again. It should run smoothly

Solution 14 - Java

Solution (for me): In my case the file was no longer existing wherever it was linked from, hence the file could not be found ( obvious ). All of the files being referenced are in paths in my src folder somewhere or in other local projects. Nothing so far has worked for me except the following...

How I was able to remove my broken links.

  • Open Eclipse, open project
  • Go to folder (in explorer) where the file is being referenced from.
  • Create a file (blank/empty) with the same name as the file being referenced (ie: "File.java").
  • Go back into eclipse and refresh project.
  • Now you can delete the file that is now being found.

Link removed.

This is a dirty workaround. I do hope that this issue is resolved however.

Solution 15 - Java

just adding to the knowldege base. i've had this problem. restarting eclipse or windows did not fix it.

deleting .metatdata/.lock in the parent directory after closing eclipse did fix the problem. iirc, sometimes you need to reboot windoze.

Solution 16 - Java

1 - Clean your project by going to Project -> Clean.

2 - Make sure you check Project -> Build automatically.

But before that, check the permissions on the src and target folders of your project, eclipse needs to read and write to those folders, then release the permissions for it. Your problem will be solved.

Solution 17 - Java

This issue came to me when permission of the project directory are changed. Make sure user has write permission to the Project directory. If there are no permission to write to Project directory then eclipse will fail to delete/create Bin folder.

To Resolve it, I gave write permission to Project directory.

Ex: sudo chmod -R 777 /MyProject/code (In my case I used Ubuntu, according to OS make sure you give write permission)

Solution 18 - Java

I had the same problem. After restarting Eclipse, one delete goes through for me and then subsequent deletes fail. What I finally did was restart Eclipse then Ctrl + click every item I wanted to delete. Then I deleted them all at once and it worked fine.

Solution 19 - Java

On windows, i've opened eclipse with Admin privilige. The problem has gone.

Solution 20 - Java

I haven't read all the previous replies, but I also have the same issue. I'm running Eclipse 4.1 on Ubuntu 12.10, 64 Bit, and a SSD. I realized that this deletion issue always comes up when my computer crashes with an opened Eclipse. I managed to solve the issue by deleting particular index files. For example, my workspace log file (located at /.metadata/.log) was full with EOFException, saying that some metadata could not be read, such as

!ENTRY org.eclipse.ui.ide 4 4 2012-12-13 13:25:35.988
!MESSAGE Problems occurred refreshing the selected resources.
!SUBENTRY 1 org.eclipse.core.resources 4 567 2012-12-13 13:25:35.988
!MESSAGE Could not read metadata for '/home/xyzworkspace/.metadata/.plugins/org.eclipse.core.resources/.projects/server-test/.indexes/7/9c/properties.index'.
!STACK 0
java.io.EOFException
	at java.io.DataInputStream.readByte(DataInputStream.java:250)
	at org.eclipse.core.internal.localstore.Bucket.load(Bucket.java:298)
	at org.eclipse.core.internal.properties.PropertyBucket.load(PropertyBucket.java:258)
	at org.eclipse.core.internal.localstore.Bucket.load(Bucket.java:274)
	at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:98)
	at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:109)
	at org.eclipse.core.internal.localstore.BucketTree.internalAccept(BucketTree.java:109)
	at org.eclipse.core.internal.localstore.BucketTree.accept(BucketTree.java:76)
	at org.eclipse.core.internal.properties.PropertyManager2.deleteProperties(PropertyManager2.java:102)
	at org.eclipse.core.internal.properties.PropertyManager2.deleteResource(PropertyManager2.java:111)
	at org.eclipse.core.internal.resources.Resource.deleteResource(Resource.java:918)
	... here goes the rest of the stack trace...

After deleting this particular index file and restarting Eclipse, everything worked as before. Any feedback whether the suggestion worked is appreciated.

Solution 21 - Java

I had to end chromedriver before I could clean my project. There were processes in the task manager that needed to be closed.

Solution 22 - Java

Process Explorer showed that the Android Java .jar file that could not be deleted was used by javaw, a sub-process of Eclipse...

This seems buggy.

The workaround is to close Eclipse and delete the file from Explorer...

Solution 23 - Java

I followed these steps to get rid of this:

  • Close eclipse
  • Go to task manager-->processes-->java.exe-->end process
  • select javaw.exe-->end process
  • Then go to project location delete it
  • start eclipse and delete the project

cheers... That's it..

Solution 24 - Java

Just hit myself with same problem: could not clean / rebuild Eclipse project, because my classes output folder could not be deleted.

I closed Eclipse and tried to delete the folder. Windows complained it is used by other application.

Being on Windows, I run resmon.exe from Windows / Search bar. Then going in CPU tab / Associated Handles I search for that folder path and I found handle for it from OUTLOOK. I sent a mail with a file from that path and it seems OUTLOOK kept it. After deleting the handle entry, everything worked again.

Solution 25 - Java

Sometimes it can be resolved simply by cleaning the project and rebuilding it. This worked for me just before.

In addition, clicking 'Build Automatically' in the 'Project' tab is usually more convenient for resolving minor problems.

Solution 26 - Java

It works for me:

  1. Close Eclipse.
  2. Remove from Eclipse Folder in your proyect, all the data inside classes.
  3. Open Eclipse.
  4. Team -> CleanUp

Solution 27 - Java

I fixed this by disabling windows search indexing. I seem to remember quite a while ago I tried to search my project folder using windows file explorer. I guess windows has kept it's search index up-to-date since then by scanning the folder and is now bumping heads with eclipse clean.

To disable:

  1. Control Panel
  2. Administrative Tools
  3. Services
  4. Find "windows search"
  5. Disable it

Since windows search is broken, I don't use it anyway. I use agent ransack for searching.

Solution 28 - Java

Update Spring Boots!

I had the same issue where my spring tool suite threw this error[Windows 7] whenever I make changes to the JSP or resources(css, js, images). It would allow one time save though to reflect the changes but the second time, STS would throw the error that it could not delete the file that I changed [basically could not move the file to bin folder]. I have to stop the application, do project -> clean for the error to go, make the changes and have to start the application. Process explorer said that javaw is having the handle on bindirectory.

I tried all suggestions that are listed as answers - Recreated the workspace, checked project references, updated my Spring tools suite, disabling windows search, indexing, etc. But none worked.

Finally I updated my spring boots from 1.4.0 to 1.5.4 and the error disappeared. So if any of you using Spring Boots facing this issue, check your version and update. You may also need to add spring-boot-devtools to enable hot-swapping with the latest spring boots versions.

Solution 29 - Java

I went to the Java Build Path ->Source (tab) ,changed the path of the Default Output folder to some other folder like customerConfig/bin to customerConfig/bins ,did a build , the error went away and then went back and changed it back to customerConfig/bin

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKáGéView Question on Stackoverflow
Solution 1 - JavaChris DolanView Answer on Stackoverflow
Solution 2 - JavaMatthew FarwellView Answer on Stackoverflow
Solution 3 - JavahamzaliView Answer on Stackoverflow
Solution 4 - Javagazonk.delView Answer on Stackoverflow
Solution 5 - JavaThorbjørn Ravn AndersenView Answer on Stackoverflow
Solution 6 - Javasina72View Answer on Stackoverflow
Solution 7 - JavaollinsView Answer on Stackoverflow
Solution 8 - JavaJoshua StaffordView Answer on Stackoverflow
Solution 9 - JavaDonald KlopperView Answer on Stackoverflow
Solution 10 - JavaDanView Answer on Stackoverflow
Solution 11 - JavaVinodView Answer on Stackoverflow
Solution 12 - JavareadikusView Answer on Stackoverflow
Solution 13 - JavaKarthik RamakrishnanView Answer on Stackoverflow
Solution 14 - Javauser1201763View Answer on Stackoverflow
Solution 15 - JavaRay TayekView Answer on Stackoverflow
Solution 16 - JavaPaulo Linhares - PackappsView Answer on Stackoverflow
Solution 17 - JavaShiv BuyyaView Answer on Stackoverflow
Solution 18 - JavaMatt SgarlataView Answer on Stackoverflow
Solution 19 - JavaercuView Answer on Stackoverflow
Solution 20 - JavanastraView Answer on Stackoverflow
Solution 21 - Javaobesechicken13View Answer on Stackoverflow
Solution 22 - JavaKrisWebDevView Answer on Stackoverflow
Solution 23 - JavaShailendra MaddaView Answer on Stackoverflow
Solution 24 - JavalittlebearView Answer on Stackoverflow
Solution 25 - JavaTomView Answer on Stackoverflow
Solution 26 - JavajavaboygoView Answer on Stackoverflow
Solution 27 - Javalance-javaView Answer on Stackoverflow
Solution 28 - JavaArun ChristopherView Answer on Stackoverflow
Solution 29 - JavaVivView Answer on Stackoverflow