Shay Shmeltzer's Oracle Development Tools Tips

FindBugs integration with JDeveloper

Shay Shmeltzer
Director of Product Management - Oracle

Picking up from yesterday's post about using the External Tools->Ant Operation to integrate third party utilities into JDeveloper, here is a quick entry that shows how to integrate the FindBugs utility in a similar way. (You should probably watch the Checkstyle video first).

First get findBugs and extract it onto your hard drive (in my case I extracted it to C: to get the folder C:/findbugs-2.0.0.

Then in that directory I created the following ant build file:

<?xml version="1.0" encoding="windows-1252" ?>
<project xmlns="antlib:org.apache.tools.ant" default="init">
<taskdef name="findbugs" classname="edu.umd.cs.findbugs.anttask.FindBugsTask"/>
  <target name="init">
  <property name="findbugs.home" value="C:/findbugs-2.0.0" />
  <target name="findbugs">
    <findbugs home="${findbugs.home}" output="text">   
      <sourcePath path="${basedir2}/src/java" />
      <class location="${basedir2}/classes" />

When you create the External Tools -> Ant operation you'll point to that file and choose the findbugs operation. You then define basedir2 as a property of the Ant operation and uses the ${project.dir} value in JDeveloper. And you can then have this operation in your tools menu. Don't forget to add the  C:\findbugs-2.0.0\lib\findbugs-ant.jar file to your Ant Classpath in step 6 of the external tools wizard.

Since FindBugs scans your classes you should first compile your project, then to run just stand on a file in your project and choose the findbugs operation in your tools menu - this will scan the full project and report the suspected bugs in your Ant log window.

Something like this:

Join the discussion

Comments ( 2 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.