5.21.2010

Debug Your JME App

Findbugs™ is one really super cool tool for Java developers. It does excellent in locating errors in the source code especially those that are not obvious to the programmer's eye. One interesting thing is that it can also analyze Java applications for MIDP devices.

Here's a simple how-to-use for you if you want to analyze your JME project.

1. Download the Findbugs™ application.
2. Extract the contents of the zip file to any directory.
3. Go to bin folder and execute findbugs.bat.
4. To start a new analysis select File > New Project.
5. Write a name on the Project name field.
6. (I suppose you already have the jar file of your project at this point.) On Class archives and directories to analyze, click Add and then select the jar file to be analyzed. Make sure that the target jar was built without any obfuscation.
7. For Auxillary class locations, select Add then locate the JSR jar files that were used/imported in your JME project. By default, these JSR files are bundled with NetBeans so if you are using NetBeans IDE look for them in the NetBeans intallation directory (they are located in the [NetBeans 6.8] mobility8 folder... and I'm not yet sure about Eclipse... I haven't used Eclipse for a while). If you are not sure which to add, select all of the jar files.
8. For Source directories just select the source code folder. Example, C:\Myporject\src
9. Finally, click Finish. Analysis will start immediately.

Note that not every bug that are detected in the analysis is valid. You have the option to tag its validity. Yet this tool is very effective in detecting a number of errors in your code that you failed to notice maybe because of the structure of the code, or its complexity, or maybe because of your style of coding.