A possible bug with Netbeans, it's executing the old code I changed

无人久伴 提交于 2019-12-10 09:40:26

问题


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 ?


回答1:


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.




回答2:


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 the build 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




回答3:


it is not really the cache problem. If you are working with netbeans :

  1. Right click on the project
  2. Navigate to properties and click it
  3. Click on the run circle(button)
  4. change the main class to your preferred main class
  5. Click ok
    It should work now


来源:https://stackoverflow.com/questions/8926483/a-possible-bug-with-netbeans-its-executing-the-old-code-i-changed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!