简体   繁体   English

删除一个.class文件似乎仍然存在的.java后,如何清理eclipse项目?

[英]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.

相关问题 如何在Eclipse中备份我的java项目? - How can I back-up my java project in Eclipse? 如何清理Java流? - How can I clean up my Java Streams? 为什么我不能在Eclipse Maven项目中将类导入到我的java文件中? - Why can't I import a class into my java file in my Eclipse Maven Project? 如何让eclipse在我的m2e maven项目中检测到新的Java类? - How can I make eclipse detect my new java class in my m2e maven project? 我可以在网络上的某个位置托管ServerSocket或Java文件吗? - Can i host my ServerSocket or Java file somewhere on the web? 如何在类路径的某处找到包含特定类的文件? - How can I find the file containing a specific class somewhere in my classpath? 如何在Eclipse中的项目中包含.class文件? (JAVA) - How do I include .class files in my project in Eclipse? (Java) 我直接在src文件夹中添加了一个库,Eclipse似乎可以正确编译,但是找不到类文件? - I added a library directly to my src folder, Eclipse seems to be compiling properly, but can't find the class file? 在Java EE项目中,删除类后,我无法找回它们吗? - In a Java EE project, after deleting my classes, I can't get them back? 如何使Maven设置(并保持最新)我的Eclipse项目的构建路径? - How can I make Maven set up (and keep up to date) the build path for my Eclipse project?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM