• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html><head>
2      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
3   <title>Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs&#8482; Manual"><link rel="up" href="index.html" title="FindBugs&#8482; Manual"><link rel="prev" href="anttask.html" title="Chapter&nbsp;6.&nbsp;Using the FindBugs&#8482; Ant task"><link rel="next" href="filter.html" title="Chapter&nbsp;8.&nbsp;Filter Files"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter&nbsp;7.&nbsp;Using the FindBugs&#8482; Eclipse plugin"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>Chapter&nbsp;7.&nbsp;Using the <span class="application">FindBugs</span>&#8482; Eclipse plugin</h2></div></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><span class="sect1"><a href="eclipse.html#d0e1662">1. Requirements</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1670">2. Installation</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1717">3. Using the Plugin</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1748">4. Extending the Eclipse Plugin (since 2.0.0)</a></span></dt><dt><span class="sect1"><a href="eclipse.html#d0e1802">5. Troubleshooting</a></span></dt></dl></div><p>
4The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to be used within
5the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE.
6The FindBugs Eclipse plugin was generously contributed by Peter Friese.
7Phil Crosby and Andrei Loskutov contributed major improvements
8to the plugin.
9</p><div class="sect1" title="1.&nbsp;Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1662"></a>1.&nbsp;Requirements</h2></div></div></div><p>
10To use the <span class="application">FindBugs</span> Plugin for Eclipse, you need Eclipse 3.3 or later,
11and JRE/JDK 1.5 or later.
12</p></div><div class="sect1" title="2.&nbsp;Installation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1670"></a>2.&nbsp;Installation</h2></div></div></div><p>
13  We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates.
14  There are three different update sites</p><div class="variablelist" title="FindBugs Eclipse update sites"><p class="title"><b>FindBugs Eclipse update sites</b></p><dl><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse/" target="_top">http://findbugs.cs.umd.edu/eclipse/</a></span></dt><dd><p>
15       Only provides official releases of FindBugs.
16      </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-candidate/" target="_top">http://findbugs.cs.umd.edu/eclipse-candidate/</a></span></dt><dd><p>
17          Provides official releases and release candidates of FindBugs.
18        </p></dd><dt><span class="term"><a class="ulink" href="http://findbugs.cs.umd.edu/eclipse-daily/" target="_top">http://findbugs.cs.umd.edu/eclipse-daily/</a></span></dt><dd><p>
19         Provides the daily build of FindBugs. No testing other than that it compiles.
20        </p></dd></dl></div><p>You can also manually
21download the plugin from the following link:
22<a class="ulink" href="http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download" target="_top">http://prdownloads.sourceforge.net/findbugs/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122.zip?download</a>.
23Extract it in Eclipse's "plugins" subdirectory.
24(So &lt;eclipse_install_dir&gt;/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png
25should be the path to the <span class="application">FindBugs</span> logo.)
26
27</p><p>
28Once the plugin is extracted, start Eclipse and choose
29<span class="guimenu">Help</span> &#8594; <span class="guimenuitem">About Eclipse Platform</span> &#8594; <span class="guimenuitem">Plug-in Details</span>.
30You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project".
31</p></div><div class="sect1" title="3.&nbsp;Using the Plugin"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1717"></a>3.&nbsp;Using the Plugin</h2></div></div></div><p>
32To get started, right click on a Java project in Package Explorer,
33and select the option labeled "Find Bugs".
34<span class="application">FindBugs</span> will run, and problem markers (displayed in source
35windows, and also in the Eclipse Problems view) will point to
36locations in your code which have been identified as potential instances
37of bug patterns.
38</p><p>
39You can also run <span class="application">FindBugs</span> on existing java archives (jar, ear, zip, war etc). Simply
40create an empty Java project and attach archives to the project classpath. Having that, you
41can now right click the archive node in Package Explorer and select the option labeled
42"Find Bugs". If you additionally configure the source code locations for the binaries,
43<span class="application">FindBugs</span> will also link the generated warnings to the right source files.
44</p><p>
45You may customize how <span class="application">FindBugs</span> runs by opening the Properties
46dialog for a Java project, and choosing the "Findbugs" property page.
47Options you may choose include:
48</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
49    Enable or disable the "Run FindBugs Automatically" checkbox.
50    When enabled, FindBugs will run every time you modify a Java class
51    within the project.
52    </p></li><li class="listitem"><p>
53    Choose minimum warning priority and enabled bug categories.
54    These options will choose which warnings are shown.
55    For example, if you select the "Medium" warning priority,
56    only Medium and High priority warnings will be shown.
57    Similarly, if you uncheck the "Style" checkbox, no warnings
58    in the Style category will be displayed.
59    </p></li><li class="listitem"><p>
60    Select detectors.  The table allows you to select which detectors
61    you want to enable for your project.
62    </p></li></ul></div></div><div class="sect1" title="4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1748"></a>4.&nbsp;Extending the Eclipse Plugin (since 2.0.0)</h2></div></div></div><p>
63Eclipse plugin supports contribution of custom <span class="application">FindBugs</span> detectors (see also
64<a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
65for more information). There are two ways to contribute custom plugins to the Eclipse:
66</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
67    Existing standard <span class="application">FindBugs</span> detector packages can be configured via
68    <span class="guimenu">Window</span> &#8594; <span class="guimenuitem">Preferences</span> &#8594; <span class="guimenuitem">Java</span> &#8594; <span class="guimenuitem"><span class="application">FindBugs</span></span> &#8594; <span class="guimenuitem">Misc. Settings</span> &#8594; <span class="guimenuitem">Custom Detectors</span>.
69    Simply specify there locations of any additional plugin libraries.
70    </p><p>
71    The benefit of this solution is that already existing detector packages can be
72    used "as is", and that you can quickly verify the quality of third party detectors.
73    The drawback is that you have to apply this settings in each
74    new Eclipse workspace, and this settings can't be shared between team members.
75    </p></li><li class="listitem"><p>
76    It is possible to contribute custom detectors via standard Eclipse extensions mechanism.
77    </p><p>
78    Please check the documentation of the
79    <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd" target="_top">
80    findBugsEclipsePlugin/schema/detectorPlugins.exsd</a>
81    extension point how to update the plugin.xml. Existing <span class="application">FindBugs</span> detector plugins can
82    be easily "extended" to be full featured <span class="application">FindBugs</span> AND Eclipse detector plugins.
83    Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and
84    update your build scripts to not to override the MANIFEST.MF during the build.
85    </p><p>
86    The benefit of this solution is that for given (shared) Eclipse installation
87    each team member has exactly same detectors set, and there is no need to configure
88    anything anymore. The (really small) precondition
89    is that you have to convert your existing detectors package to the valid
90    Eclipse plugin. You can do this even for third-party detector packages.
91    Another major differentiator is the ability to extend the default FindBugs
92    classpath at runtime with required third party libraries (see
93    <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a>
94    for more information).
95    </p></li></ul></div></div><div class="sect1" title="5.&nbsp;Troubleshooting"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1802"></a>5.&nbsp;Troubleshooting</h2></div></div></div><p>
96This section lists common problems with the plugin and (if known) how to resolve them.
97</p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p>
98    If you see OutOfMemory error dialogs after starting <span class="application">FindBugs</span> analysis in Eclipse,
99    please increase JVM available memory: change eclipse.ini and add the lines below
100    to the end of the file:
101    </p><pre class="programlisting">
102    -vmargs
103    -Xmx1000m
104    </pre><p>
105    Important: the configuration arguments starting with the line "-vmargs" must
106    be last lines in the eclipse.ini file, and only one argument per line is allowed!
107    </p></li><li class="listitem"><p>
108    If you do not see any <span class="application">FindBugs</span> problem markers (in your source
109    windows or in the Problems View), you may need to change your
110    Problems View filter settings.  See
111    <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information.
112    </p></li></ul></div></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="anttask.html">Prev</a>&nbsp;</td><td width="20%" align="center">&nbsp;</td><td width="40%" align="right">&nbsp;<a accesskey="n" href="filter.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter&nbsp;6.&nbsp;Using the <span class="application">FindBugs</span>&#8482; <span class="application">Ant</span> task&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&nbsp;Chapter&nbsp;8.&nbsp;Filter Files</td></tr></table></div></body></html>