Tuesday 8 May 2012

When Re-Installing NetBeans Does Not Solve Strange Issues...

This post is a reminder of a trick I found to solve strange behaviors with NetBeans, when re-installation does not solve those issues.

Although I have not encountered these issues recently (I am currently using NetBeans 7.1.1), there are situations where NetBeans starts to behave in strange ways:
  • Project scanning seems to enter an infinite loop
  • Projects won't compile anymore or compilation enters an infinite loop
  • Project error messages are displayed, thought there is actually no error in the code or in the configuration (for example java.lang.NoClassDefFoundError)
  • NetBeans claims that code is syntactically incorrect, though it is not
  • Project dependencies are not found anymore, though they are physically available on your PC
NetBeans becomes unusable. When re-installing NetBeans, the issues remain. I have noticed a trend. These seem to happen after NetBeans has crashed or was abruptly interrupted (by killing the corresponding process in Windows' task manager for example).

It took me quite some time to find this, but actually, when you uninstall NetBeans, this does not necessarily erase the existing cache. The uninstallation process asks you whether you want to keep your configuration. It also means keeping your cache too. Hence, since I kept my configuration, I also kept my existing cache.

It seems like all the issues described above were caused by a corrupted cache. The solution is simple and does not require you to uninstall NetBeans:
  1. Close any instance of the NetBeans application.
  2. If you are under windows, locate the C:\Users\[YourLoginId]\.netbeans\[netbeans_version]\var\cache\ directory. If you are using Unix, this would be something like ~\.netbeans\[netbeans_version]\var\cache\. (*)
  3. Delete it. Don't worry, NetBeans will recreate it.
  4. Restart NetBeans.
The price of this solution is that NetBeans will rescan all your projects and you may loose some of your NetBeans configuration. If this does not work, you can go as far as deleting the \var directory after shutting down NetBeans.

This always worked for me.

(*) Starting from Netbeans 7.2, the path is now:

    C:\Users\[YourLoginId]\AppData\Roaming\NetBeans\[netbeans_version]\var\

No comments:

Post a Comment