[英]How can I clean up my eclipse project after deleting a .java whose .class file still seems to be somewhere?
So, I deleted a couple of .java
files from within eclipse because I didn't need them anymore. 因此,我从Eclipse中删除了几个
.java
文件,因为我不再需要它们了。 However for some reason another class still uses them and compiles without a problem. 但是由于某种原因,另一个类仍会使用它们并且可以毫无问题地进行编译。 When I go to the declaration of the constructor of one of the deleted classes a
.class
file opens of that class even though I thought they got deleted by eclipse when I deleted their .java
files. 当我转到已删除类之一的构造函数的声明时,即使该类在我删除它们的
.java
文件时被eclipse删除,也会打开该类的.class
文件。
I have tried to clean the project and I tried to find the .class
file using the system file explorer in the folders that are listed in 我尝试清理项目,并尝试使用系统文件浏览器在列出的文件夹中找到
.class
文件。
project > properties > resource > linked resources. However I couldn't find them.
Now, since I deleted those files/classes there should be a compile time error wherever they are used but everything compiles without an error, even using the code that should've gotten deleted. 现在,由于我删除了这些文件/类,因此无论在何处使用它们都应该出现编译时错误,但即使使用应删除的代码,所有内容也都不会出错。 A colleague that recently joined the project does receive compile time errors, since he doesn't have those class files.
最近加入该项目的同事确实会收到编译时错误,因为他没有这些类文件。 And I want to get them too, so I can fix the code where the classes were used.
而且我也想获得它们,因此我可以在使用类的地方修复代码。 Of course he could show me the lines of code that are affected but if this happens again he would probably be affected as well as he would have the class files by then.
当然,他可以向我展示受影响的代码行,但是如果再次发生这种情况,他可能会受到影响,并且届时他将拥有类文件。
Try doing the following 尝试执行以下操作
Go to project > properties > Java Build path >Source
转到项目>属性> Java构建路径>源
under that you can find Default Output Folder section, simply delete the classes folder under that location with in your project. 在该目录下,您可以找到“默认输出文件夹”部分,只需删除项目中该位置下的classes文件夹即可。
Try cleaning the project. 尝试清理项目。
Or 要么
Simply close the eclipse and reopen it again, sometime this would work for me. 只需关闭月食并再次将其重新打开,有时对我来说这是可行的。 Hope it resolves your problem
希望它能解决您的问题
If you just deleted the sources, they binaries would still be there. 如果您只是删除源,则它们的二进制文件仍将存在。 So open the
Navigator View
and go to the project in question. 因此,打开
Navigator View
并转到有问题的项目。 Look for the bin
directory and delete the appropriate class files. 查找
bin
目录并删除相应的类文件。 Otherwise, delete the project itself. 否则,删除项目本身。
You should also ensure that no other programs depend on those class files. 您还应确保没有其他程序依赖于这些类文件。
I found the problem. 我发现了问题。 Someone built a .jar file I didn't know of which contained a lot of old code.
有人构建了一个.jar文件,我不知道其中包含很多旧代码。 I found it by right clicking the constructor and selecting
我通过右键单击构造函数并选择
references>project
参考文献>项目
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.