So I’ve been working on a Java project recently, which, in terms of sheer lines of code, is pretty substantial. As such, I work on it a lot in different locations, and usually split the work between my two computers. Me being the efficiency freak that I am, I have found ways to ensure that the current version of the project is always accessible from anywhere on any system I’m using. That is, I keep the source files in the cloud (via Dropbox), so that every time I save a change in Netbeans it’s automatically uploaded, and I keep disk backups of the current files (done by a shell script every time I close a session). So basically the source directory that Netbeans looks at is just symlinked from Dropbox, while the class files are kept locally on each computer that I’m working on (apparently the Linux and Mac JVMs are different enough to require an annoying recompile if you don’t do this). But everything that I’m doing with this stuff is controlled by shell scripts.
The thing is, I started to notice that if I ever save anything in Netbeans when I’m not connected to Dropbox (that is, Dropbox fails to sync) I start getting errors about “uncompilable source code”. The identical code still runs just fine from the command line, but Netbeans can’t handle it. I finally found the answer to this issue today, though – it turns out that when Netbeans is set to compile every time the file is saved, a separate set of class files are created for debugging purposes. Certain things can cause these files to be corrupted and uncompilable, such as, I found out, a nonsyncing Dropbox containing the source files.
So to fix this, I first turned off the “compile on save” feature in Project Properties, then deleted closed Netbeans and deleted the directory “.netbeans/6.9/var/cache/index” (where the cache of extra class files is kept) and reopened. The directory is automatically recreated in a noncorrupted state when Netbeans reopens. The problem of uncompilable source code is gone now, with the one added annoyance of having to manually compile before running. Still, I’m glad my project runs.