FindBugs – It really find the bugs !
I have used it for the first time, and no wonder it goes by its name, it really find the bugs , absolutely brillant tool, I think that every java programmer must have in his kitty.
Let me start off with a very short description of what is it all about, it is a static analysis tool which is used to find the bugs. It will analyze the byte codes and let give you a statistical report which you can see to find out the bugs, i would say the potential bugs. It mainly concentrates on isolating potentially harmful coding errors that can break an application. This tool can find potentially harmful bugs that other static analysis tools will not detect.
It will find existing bugs in your code without requiring much effort on the part of the developer, you just need to know how to use the tool and your job is done.
You will require following things before you can start off with this tool:
- JDK 1.4 or Higher
- Make sure your JAVA_HOME is correctly set, you will require this for running findbugs.
- FindBugs jar files(You can download the latest from SourceForget.net site)
- Last but the most obvious thing a project which you are going to analyze using this tool.
There are various ways of using the tool , here i am going show you the most basic way of using the tools that is using the GUI which comes with this tool.
Follow these steps:
- Unzip the FindBugs zip you downloaded say to C:\Utility folder.
- Go to the folder C:\Utility\findbugs-x.x.x\bin , here you will find “findbugs.bat” file, just double click it. If you JAVA_HOME is set correctly ,you should see the following screen.

- Now go to file menu and select New Project Option , you will see the following screen, here you enter the name of the project , I have entered it here name of the project as “TestAnalysis”.

- Now you click on the “Add” button next to “Class Archives and directories to analyze”, you will be asked to select the compiled version of your classes in either .jar,.war, .ear or .zip form, select the appropriate file. It works on compiled files to analyze the pattern. As you can see I have selected a “.war” file for this example.

- You can leave “Auxiliary Class Location” blank, you can even leave “Source Directories” blank , but if you leave this option blank you would not be able to see the source file in findbugs window, you will be shown only the line no. and name of the java file, so it is better to choose the source location, so you can click on add button and point it to your source directory as I have done below.

- Now click on the finish button, you will see the following screen, it might take time analyzing depending upon no of java classes .

- Once it will finish analyzing you will see a screen very similar to that is shown below. It categorizes the bugs it has found. Like in my case it found some 17 bugs, you can expand those categories and see all the bugs found.

- If you have selected the “Source Directories” while creating new project, you will the source code on the right hand side under the “Source” section. And on the bottom half of screen you will find the description of the bug , along with line number and file name.

Rest of the options you can simply explore as it is very easy to use. I will show you how to configure this in eclipse and to integrate it with build process in my next articles soon.
I hope you enjoyed learning. Feedback on this will really be appreciated.
Related posts:







Information is useful.
Thanks I was looking for starting it and the article shows me that only.It would be great if you could tell how to integrate it with the build process.
I have been following up on this blog for a while and i find it very impressive. I plan to add it to my rss feeds
After reading through the article, I feel that I really need more information on the topic. Can you share some more resources ?
sites such as these are great because everyone can share ideas and thoughts,no matter if anyone agrees with them or not.kepp up the good work and i hope i can contribute as well
Is there any open source counterpart for this????
I need it for linux
Although i have not tried , but it can run in both linux and windows.
@Ruchi
Thanks, it works in Linux too……
Really nice find:)