Java Eclipse 无法删除错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2660961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-13 10:28:04  来源:igfitidea点击:

Eclipse could not delete error

javaeclipsebuild

提问by KáGé

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,

我正在使用 Eclipse 处理一个项目,现在一切正常,但是上次我尝试构建它时,它返回了错误,

"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"

“由于“无法删除'/Torpedo/bin/bin',该项目未构建。”解决问题,然后尝试刷新此项目并构建它,因为它可能与 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?

它删除了我的 bin 文件夹,其中存储了程序所需的所有图像和内容。(幸运的是我有备份)。我试过谷歌搜索并尝试了我找到的所有解决方案,但没有任何帮助,而且大多数人建议手动删除文件夹,但我不能。我该怎么办?

回答by Chris Dolan

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.

我在 Windows 上经常看到这个。我认为这是 Eclipse 中的错误或竞争,也许是与病毒检查程序的竞争,它不喜欢立即删除,然后写入已删除的同一个文件。我使用的修复方法是从菜单栏中使用 Project -- Clean。

@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"

@Ash 在上面的评论中是正确的,您的输出文件夹中不应该有资源。为了避免这种情况,我总是将输出文件夹的名称从“bin”更改为更明显的名称,例如“eclipse/classes”

回答by Thorbj?rn Ravn Andersen

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

在 Windows 下为我删除内容的问题通常归结为以下两件事之一:

  • 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.
  • 由程序打开的文件。这包括JVM。这通常不会自行消失。
  • 计算机上的防病毒程序已打开该文件以供其执行任何操作。这通常会在一段时间后消失。我经常重新创建工作区,如果这种情况发生得太快,Eclipse 会抱怨它无法删除文件。

回答by Donald Klopper

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.

我刚刚遇到了这个问题......这是因为我在 BIN 树的文件夹中为我正在构建的项目打开了一个命令行会话(DOS 屏幕......)......我想运行通过命令行的 .class 文件。

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

解决方案只是将 cd 返回到 bin 文件夹,以便“清理”可以删除并重新创建这些目标文件夹。

回答by Dan

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.

这只是发生在我身上。我在它发生时关闭了用户访问控制 (UAC)(Windows Vista 32 位)。我重新打开了 UAC,重新启动了 vista,然后错误消失了。反直觉的是,在 UAC 关闭的情况下,删除 bin/net 目录会失败,但在 UAC 重新打开时它可以工作。去搞清楚。

回答by user393274

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.

我有同样的问题。重新启动 Eclipse 后,我执行了一次删除操作,然后后续删除操作失败。我最后做的是重新启动 Eclipse,然后 Ctrl + 单击我想删除的每个项目。然后我立即将它们全部删除,并且效果很好。

回答by sina72

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.

检查是否有任何其他进程正在使用目标“bin”文件夹中的文件,然后将其杀死。这通常发生在从 Eclipse 调用的其他 Java 进程中。

回答by ercu

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

在 Windows 上,我以管理员权限打开了 eclipse。问题已经过去了。

回答by Matthew Farwell

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.

我半定期地遇到这个问题,特别是在 Windows 7 下部署到 Tomcat 等时。它也发生在我的 maven 命令行版本中,所以不仅仅是 Eclipse 有这个问题。

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.

根本原因是文件句柄上有东西。当我在 PC 上禁用 Windows 搜索/索引时,大多数问题都消失了,但有时仍然会出现问题。

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.

要追踪正在发生的事情,您需要下载Process Explorer(我遇到过的最有用的程序之一)。这使您可以准确查看 PC 上正在运行的内容、打开的文件、进程的性能、正在运行的 CPU 数量、正在执行的 IO 数量等。当您有无法删除的文件时, 你可以 Find->Find Handle or DLL, 然后输入部分名称,它会告诉你谁打开了它。你并不总是及时抓住它,但往往足以知道罪魁祸首。

enter image description here

在此处输入图片说明

回答by ollins

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

我在 Windows XP/Vista 上遇到了类似的问题。就我而言,文件的总长度超过 255 个字符。

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

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

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

我找到的唯一解决方案是重命名目录,使其短于 255 个字符。

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

/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.

之后你可以删除它。这是 windows API 中的一个限制。文件系统可以管理超过 255 个字符,但不能管理使用 windows api 的资源管理器。

回答by Vinod

The process I followed is

我遵循的过程是

  1. Close eclipse
  2. Explore to the folder
  3. Delete it
  1. 关闭日食
  2. 浏览到文件夹
  3. 删除它