| <html><head> |
| <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> |
| <title>Chapter 7. Using the FindBugs™ Eclipse plugin</title><meta name="generator" content="DocBook XSL Stylesheets V1.76.1"><link rel="home" href="index.html" title="FindBugs™ Manual"><link rel="up" href="index.html" title="FindBugs™ Manual"><link rel="prev" href="anttask.html" title="Chapter 6. Using the FindBugs™ Ant task"><link rel="next" href="filter.html" title="Chapter 8. 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 7. Using the <span class="application">FindBugs</span>™ Eclipse plugin</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="anttask.html">Prev</a> </td><th width="60%" align="center"> </th><td width="20%" align="right"> <a accesskey="n" href="filter.html">Next</a></td></tr></table><hr></div><div class="chapter" title="Chapter 7. Using the FindBugs™ Eclipse plugin"><div class="titlepage"><div><div><h2 class="title"><a name="eclipse"></a>Chapter 7. Using the <span class="application">FindBugs</span>™ 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> |
| The FindBugs Eclipse plugin allows <span class="application">FindBugs</span> to be used within |
| the <a class="ulink" href="http://www.eclipse.org/" target="_top">Eclipse</a> IDE. |
| The FindBugs Eclipse plugin was generously contributed by Peter Friese. |
| Phil Crosby and Andrei Loskutov contributed major improvements |
| to the plugin. |
| </p><div class="sect1" title="1. Requirements"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1662"></a>1. Requirements</h2></div></div></div><p> |
| To use the <span class="application">FindBugs</span> Plugin for Eclipse, you need Eclipse 3.3 or later, |
| and JRE/JDK 1.5 or later. |
| </p></div><div class="sect1" title="2. Installation"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1670"></a>2. Installation</h2></div></div></div><p> |
| We provide update sites that allow you to automatically install FindBugs into Eclipse and also query and install updates. |
| 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> |
| Only provides official releases of FindBugs. |
| </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> |
| Provides official releases and release candidates of FindBugs. |
| </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> |
| Provides the daily build of FindBugs. No testing other than that it compiles. |
| </p></dd></dl></div><p>You can also manually |
| download the plugin from the following link: |
| <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>. |
| Extract it in Eclipse's "plugins" subdirectory. |
| (So <eclipse_install_dir>/plugins/edu.umd.cs.findbugs.plugin.eclipse_2.0.3.20131122/findbugs.png |
| should be the path to the <span class="application">FindBugs</span> logo.) |
| |
| </p><p> |
| Once the plugin is extracted, start Eclipse and choose |
| <span class="guimenu">Help</span> → <span class="guimenuitem">About Eclipse Platform</span> → <span class="guimenuitem">Plug-in Details</span>. |
| You should find a plugin called "FindBugs Plug-in" provided by "FindBugs Project". |
| </p></div><div class="sect1" title="3. Using the Plugin"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1717"></a>3. Using the Plugin</h2></div></div></div><p> |
| To get started, right click on a Java project in Package Explorer, |
| and select the option labeled "Find Bugs". |
| <span class="application">FindBugs</span> will run, and problem markers (displayed in source |
| windows, and also in the Eclipse Problems view) will point to |
| locations in your code which have been identified as potential instances |
| of bug patterns. |
| </p><p> |
| You can also run <span class="application">FindBugs</span> on existing java archives (jar, ear, zip, war etc). Simply |
| create an empty Java project and attach archives to the project classpath. Having that, you |
| can now right click the archive node in Package Explorer and select the option labeled |
| "Find Bugs". If you additionally configure the source code locations for the binaries, |
| <span class="application">FindBugs</span> will also link the generated warnings to the right source files. |
| </p><p> |
| You may customize how <span class="application">FindBugs</span> runs by opening the Properties |
| dialog for a Java project, and choosing the "Findbugs" property page. |
| Options you may choose include: |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| Enable or disable the "Run FindBugs Automatically" checkbox. |
| When enabled, FindBugs will run every time you modify a Java class |
| within the project. |
| </p></li><li class="listitem"><p> |
| Choose minimum warning priority and enabled bug categories. |
| These options will choose which warnings are shown. |
| For example, if you select the "Medium" warning priority, |
| only Medium and High priority warnings will be shown. |
| Similarly, if you uncheck the "Style" checkbox, no warnings |
| in the Style category will be displayed. |
| </p></li><li class="listitem"><p> |
| Select detectors. The table allows you to select which detectors |
| you want to enable for your project. |
| </p></li></ul></div></div><div class="sect1" title="4. Extending the Eclipse Plugin (since 2.0.0)"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1748"></a>4. Extending the Eclipse Plugin (since 2.0.0)</h2></div></div></div><p> |
| Eclipse plugin supports contribution of custom <span class="application">FindBugs</span> detectors (see also |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
| for more information). There are two ways to contribute custom plugins to the Eclipse: |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| Existing standard <span class="application">FindBugs</span> detector packages can be configured via |
| <span class="guimenu">Window</span> → <span class="guimenuitem">Preferences</span> → <span class="guimenuitem">Java</span> → <span class="guimenuitem"><span class="application">FindBugs</span></span> → <span class="guimenuitem">Misc. Settings</span> → <span class="guimenuitem">Custom Detectors</span>. |
| Simply specify there locations of any additional plugin libraries. |
| </p><p> |
| The benefit of this solution is that already existing detector packages can be |
| used "as is", and that you can quickly verify the quality of third party detectors. |
| The drawback is that you have to apply this settings in each |
| new Eclipse workspace, and this settings can't be shared between team members. |
| </p></li><li class="listitem"><p> |
| It is possible to contribute custom detectors via standard Eclipse extensions mechanism. |
| </p><p> |
| Please check the documentation of the |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/eclipsePlugin/schema/detectorPlugins.exsd" target="_top"> |
| findBugsEclipsePlugin/schema/detectorPlugins.exsd</a> |
| extension point how to update the plugin.xml. Existing <span class="application">FindBugs</span> detector plugins can |
| be easily "extended" to be full featured <span class="application">FindBugs</span> AND Eclipse detector plugins. |
| Usually you only need to add META-INF/MANIFEST.MF and plugin.xml to the jar and |
| update your build scripts to not to override the MANIFEST.MF during the build. |
| </p><p> |
| The benefit of this solution is that for given (shared) Eclipse installation |
| each team member has exactly same detectors set, and there is no need to configure |
| anything anymore. The (really small) precondition |
| is that you have to convert your existing detectors package to the valid |
| Eclipse plugin. You can do this even for third-party detector packages. |
| Another major differentiator is the ability to extend the default FindBugs |
| classpath at runtime with required third party libraries (see |
| <a class="ulink" href="http://code.google.com/p/findbugs/source/browse/trunk/findbugs/src/doc/AddingDetectors.txt" target="_top">AddingDetectors.txt</a> |
| for more information). |
| </p></li></ul></div></div><div class="sect1" title="5. Troubleshooting"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="d0e1802"></a>5. Troubleshooting</h2></div></div></div><p> |
| This section lists common problems with the plugin and (if known) how to resolve them. |
| </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem"><p> |
| If you see OutOfMemory error dialogs after starting <span class="application">FindBugs</span> analysis in Eclipse, |
| please increase JVM available memory: change eclipse.ini and add the lines below |
| to the end of the file: |
| </p><pre class="programlisting"> |
| -vmargs |
| -Xmx1000m |
| </pre><p> |
| Important: the configuration arguments starting with the line "-vmargs" must |
| be last lines in the eclipse.ini file, and only one argument per line is allowed! |
| </p></li><li class="listitem"><p> |
| If you do not see any <span class="application">FindBugs</span> problem markers (in your source |
| windows or in the Problems View), you may need to change your |
| Problems View filter settings. See |
| <a class="ulink" href="http://findbugs.sourceforge.net/FAQ.html#q7" target="_top">http://findbugs.sourceforge.net/FAQ.html#q7</a> for more information. |
| </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> </td><td width="20%" align="center"> </td><td width="40%" align="right"> <a accesskey="n" href="filter.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 6. Using the <span class="application">FindBugs</span>™ <span class="application">Ant</span> task </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 8. Filter Files</td></tr></table></div></body></html> |