What is causing this Java "Cannot find symbol" error?

Most likely you're using a previously compiled class file ( which didn't have the method ) in your classpath and the system is trying to use that instead of your current source code.

Otherwise, clean up your workspace, do not depend on existing compilations and try again. This has happened to me in the past.


I keep having the same problem (though I don't know whether it's for the same reason). For me, the only thing that works (apart from ditching this "robust" IDE) is to delete the cache. On windows, it's located in %UserProfile%\.netbeans\7.0\var\cache. I suppose on *nix, it could be under ~/.netbeans/7.0/var/cache. You have to exit NetBeans first, delete the cache, then start NetBeans again.


Clean and build your project. If that doesn't work, then restart Netbeans. Sometimes Netbeans gives weird errors and a full restart of Netbeans and/or computer just seems to fix these unexplainable issues.