Mohamed Taher Alrefaie
Mohamed Taher Alrefaie

Reputation: 16233

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

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 ?

Upvotes: 3

Views: 4273

Answers (3)

Yusuf Maryam
Yusuf Maryam

Reputation: 1

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

Upvotes: 0

toto2
toto2

Reputation: 5326

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.

Upvotes: 5

MozenRath
MozenRath

Reputation: 10030

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

Upvotes: 1

Related Questions