Weird NetBeans Compilation Issue


I’m just starting with jMonektEngine and currently I’m running it in netbeans IDE. However I’ve just noticed a weird error:

I’m currently running through the tutorials and on several parts it asks you to make some changes yourself, which so far I’ve been unable to do. I make the .java file in netbeans, copy the contents of the tutorial file into it, and run it. The file runs fine and everything works as expected. However I’m unable to make any changes to the file at all. Any changes to the code I make are completely ignored, and the program uses the old code. So for example if there was a box, which was blue, I would run the program and see a blue box. But if I wanted to change the box to, lets say, red, then nothing would happen. The file would save fine, and I could quite literally stare at the line saying ‘red’ for hours on end, but the program still displays a blue box. I even checked the .java file outside of netbeans, and again stared at the line stating ‘red’, but java refused to acknowledge me and presented me with a blue box.

But then it gets even weirder. If I force netbeans to compile and build (clean and build), and then run the file on its own in the dist folder, it actually works and my box appears red. But try running it from netbeans again, and back to my blue box. This means netbeans must have been somehow running an older version of the file, but I don’t know how, why or where…

Anyone else had any issues of this type before? Any help would be appreciated!

Yes this is somewhat of a “bug” in netbeans.

One way to prevent it is to enable Project Settings → Compiling → Compile on Save.

Another way is to never use the Right Click → Run File option, but instead to run the entire project by pressing F6, this will force netbeans to rebuild the project

Why don’t you just use jMP? Its got the exact same editor etc. as netbeans and adds lots of goodies for jME development. Anyway, remove the jmetests.jar from the classpath.

I don’t particularly wan’t to use jMP because I like to keep all my projects in one place.

And sorry, but none of the above three methods helped…

Anyone else got any idea? If not, then I guess I’ll just have to use jMP

I thought jMP is Netbeans with some additions?

@captainalge Try deleting all files that are a direct result of building your project. You should have a directory called “build” or “classes” or something like that where the compiled class files go, and a directory called “dist” where the final jar and its supporting files go. Try deleting (or just moving to be on the safe side) the dist directory and the one with your compiled classes so that none of them are even there at all.

You could also try doing a search for any other artifacts left behind, searching for other jars or class files, and searching for other copies of the java files. You could do a for loop on the command line through all files in your entire project’s directory tree and search their contents for the old code, such as a search for “ColorRGBA.Blue.” On Unix, you could do a for loop through find . and cat all the files, pipe that through grep. On Windows, you can do a for loop through ‘dir /b /s’ and type all the files, pipe that through findstr.

You are probably on Windows, so something like…

(edit)Bah! Stupid code processor keeps screwing this up. I just won’t show it in a code formatting.(/edit)

for /f “tokens=*” %a in (‘dir *.java /b /s’) do @echo %a&type “%a”|findstr /N ColorRGBA.Blue&echo.

will show you which files still reference ColorRGBA.Blue, what the line contains and its line number. All files will be showed, but those without a match will just be followed by a blank line, and files with a match will show the part that matches. Run that from the root directory of your project.

Cheers for the response.

Yeah, jMP is basically Netbeans with a few additions, which could suggest that there is a problem with Netbeans as a whole. Hopefully that’s not the case.

I’ve tried everything you’ve suggested apart from your search, which I may try later.

For now though, I’ve just switched to jMP. Oh well. Thanks anyway!