Table of Contents
FindBugs has two user interfaces: a graphical user interface (GUI) and a command line user interface. This chapter describes the graphical user interface.
After you have started FindBugs using the findbugs command, choose the -> menu item. You will see a dialog which looks like this:
Use the "Browse" button next to the "Add archive or directory" text field to select a Java archive file (zip, jar, ear, or war file) or directory containing java classes to analyze for bugs. You may add multiple archives/directories.
You can also add the source directories which contain the source code for the Java archives you are analyzing. This will enable FindBugs to highlight the source code which contains a possible error. The source directories you add should be the roots of the Java package hierarchy. For example, if your application is contained in the org.foobar.myapp package, you should add the parent directory of the org directory to the source directory list for the project.
Another optional step is to add additional Jar files or directories as classpath entries. You should do this if the archives and directories you are analyzing have references to other classes which are not included in the analyzed archives/directories and are not in the standard runtime classpath. Some of the bug pattern detectors in FindBugs make use of class hierarchy information, so you will get more accurate results if the entire class hierarchy is available which FindBugs performs its analysis.
Once you have added all of the archives, directories, and source directories, click the "Find Bugs!" button to analyze the classes contained in the Jar files. Note that for a very large program on an older computer, this may take quite a while (tens of minutes). A recent computer with ample memory will typically be able to analyze a large program in only a few minutes.
When the analysis completes, you will see a screen like the following:
The top pane of the window shows the bug tree; this is a hierarchical representation of all of the potential bugs detected in the analyzed Jar files. The tabs allow you to browse by class, package, or bug type.
When you select a particular bug instance in the top pane, you will see a description of the bug in the "Details" tab of the bottom pane. In addition, the "Source code" tab of the bottom pane will, for some kinds of bugs, show the program source code where the potential bug occurs. In the above example, the bug is an access to an uninitialized field in a constructor. The source code window highlights the line containing the problematic access.
You may add a textual annotations to bug instances. To do so, choose the "Annotations" tab in the bottom pane. Simply type in any information which you would like to record. When you load and save bug results files, the annotations are preserved.
You may use the
-> menu option to save the current lists of Jar files and source directories. A saved project may be loaded with the -> menu option. Note that when you save a project, the analysis results are not saved.You may use the FindBugs on your project. The results are saved in XML format. Any annotations you have added to bug reports are saved in the resulting XML file.
-> and -> to load and save the bug results produced by running![]() | Planned Features |
---|---|
Support for loading and saving bugs is still under development. You may find bugs in this feature, and the file format and/or implementation may change in future releases. |