Rajat Gupta
Rajat Gupta

Reputation: 26587

Java code in Netbeans IDE: Code executed is the older one! even when I make changes in the code

I am building an application in Java using Netbeans IDE. I am trying to debug some errors in my code. But even when I modify messages passed in the log statements, I do not see a corresponding change in the logged messages. This implies that when execute the code, it probably runs an older version of code & prints the old version of log messages as well.

What is the cause of this error ? & how should I rectify this ?

Thanks for helping..

Upvotes: 0

Views: 1314

Answers (3)

Adeel Ansari
Adeel Ansari

Reputation: 39897

By saving the code. I assume, you are have compile-on-save enabled. If not then you have to build it before running it.

Yes you need to enable build-on-save, otherwise GlassFish wouldn't be able to show you the changes, because the new changes have never been deployed. Sometimes, deploying on save bothers a lot. So, what I do is, I don't enable build-on-save and work with tests and thereby run my tests to see the result of the change. When everything seems fine, then I build the app and deploy it on the server for further verifications.

Upvotes: 0

Luixv
Luixv

Reputation: 8710

Compile on save must be set. See the properties of your project. (Right click, select properties, then select compile). Another possibility is that you have to redeploy your project. In such a case I would recommend to take a look at jRebel.

Upvotes: 0

mixkat
mixkat

Reputation: 3785

I had that same problem...closing and reopening netbeans fixed it for me...

Upvotes: 1

Related Questions