I know this question may seems stupid since i cannot give a lot of infos about it, but I think that the problem has to be some kind of bug...
I have written a java program whith NetBeans 7.1, which now gets me this error when trying to run. 10 mins ago it was perfectly running, and i have changed nothing to the class the error refers to
Could this be some kind of NetBeans error? Maybe it is a well know problem?
It also got this exception in NB 7.2
- 'clean an build' and restarting NB didn't work
- updating NB with the latest updates and performing 'clean and build' also didn't work.
So i renamed the cache directory:
c:\Users\userabcd\AppData\Local\NetBeans\Cache\7.2\index\
started NB, waited for it to finish 'background scanning' and pressed 'Debug project' and voila. The cache gets corrupted every once in a while :-/
EDIT: Added Solution B below.
Solution A:
- Project Properties
- Build >> Compiling
-
un-check: Compile on Save
- Clean and Build
Notes A:
- If you leave Compile on Save un-checked, you won't have this problem any longer for this project.
- If you enjoy the benefits of the Compile on Save feature, you can re-check the option after you clean and build, and continue work on your project as normal.
- Compile on Save is meant to save time by constantly recompiling your .java files into .class files in the background as you save changes to your source code. That way when you build or run your project, most of the compiling work has already been completed allowing you to run and test your code quickly, even for large projects.
- NetBeans uses some fancy caching and versioning to avoid having to recompile your entire project every time you save a file. That's why the other solutions listed here will often work; they are ways of defeating this caching-and-versioning system when it occasionally fails, as it has above.
Solution B:
- Create empty folder e. g. C:\Temp\mine
- Create a new shortcut for NetBeans
with command line parameter in Target:
"C:\Program Files\NetBeans 8.2\bin\netbeans64.exe" --userdir "C:\Temp\mine"
- When compile errors occur
(ClassNotFoundException, MethodNotFoundException, etc...)
delete
C:\Temp\mine\var\cache
Notes B:
- You'll lose all your NetBeans settings the first time.
- Much easier to solve future compile errors caused by caching bugs.
- Allows running multiple copies of NetBeans, one per userdir.