Netbeans 可能存在错误,它正在执行我更改的旧代码
我一直在一个包含 500 多个类的项目中进行编码。其中一个类负责从磁盘检索数据。由于某些原因,我更改了代码,但是当我运行代码时,它仍然执行类的旧代码。当我调试时,调试器会移过空行,这意味着它仍然运行我更改的旧代码。我多次清理和构建了该项目。我手动删除了所有 .class 文件并再次构建了项目,但没有任何改变。
让我发疯的是,我将此代码复制粘贴到新项目中的新类中,并使用类中的 main 方法对其进行测试,它工作得很好。
我猜这是 netbeans 中的一个错误,或者背后有一些我不知道的东西。我使用的版本是7.1并且是最新的。
知道如何克服这个问题吗?
I have been coding in a project with over 500 class. One of the classes is responsible for retreiving data from the disk. For some reasons I changed the code, but still, when I run the code, it executes the old code of the class. When I debug, the debugger moves over empty lines which means it still runs over the old code that I have changed. I cleaned and built the project several times. I hand deleted all the .class files and built the project again and nothing changed.
What drives me crazy, is that I copy-paste this code to a new class in a new project and I test it using a main method within the class it works just fine.
I guess it's a bug in netbeans or there is something behind that i don't know about. The version I'm using is 7.1 and it's up to date.
Any idea of how to overcome this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于缓存,我遇到了一些(不同的)问题。我删除后一切正常。
在我的机器(Windows 7)上,它位于:
MyDirectory > .netbeans> 7.0>变量>缓存。
I've had some (different) issues because of the cache. Everything worked after I erased it.
On my machine (Windows 7) it's at:
MyDirectory > .netbeans > 7.0 > var > cache
.是的,这种事情在eclipse中也会发生。有时,当项目很大时,根据项目中使用的目录结构,构建可能无法正常工作。当您说正在清理和重建代码时,您是否尝试过实际删除
bin
文件夹或build
文件夹?如果你这样做,我认为你不应该再次面临这个问题。有时,一些不再引用的类可能会留在罐子中。甚至可能发生这样的情况:您的旧类仍然在您运行代码的类路径中(旧代码的 jar 可能仍然在您的类路径中)。希望这有帮助
yes, this kind of thing happens in eclipse too. Some times when the project is large the build may not work correctly based on the directory structure used in the project. when you say that you are cleaning and rebuilding the code, have you tried to actually go and delete the
bin
folder or thebuild
folder? it you do this, i think you should not face the problem again. some times some classes which are no longer referenced might be left in the jars. It could even happen that your old class is still in the classpath from where you run the code(the jars of the old code could still be in your classpath).Hope this helps
这并不是真正的缓存问题。如果您正在使用 netbeans:
现在应该可以了
it is not really the cache problem. If you are working with netbeans :
It should work now