Java Notes

Style and Correctness Checkers

PMD
Description: PMD checks for a long list of possibly bad programming practices and possible error conditions in source programs. My feeling about it is mixed -- it is undoubtedly very useful, but the number of warnings about things which were actually ok were excessive. Of course, what I should be doing it tuning the rules so it diagnoses what I think is important. I've used it from jEdit but found the interface difficult. "PMD has plugins for JDeveloper, JEdit, JBuilder, NetBeans/Sun ONE Studio, IntelliJ IDEA, TextPad, Maven, Ant, Eclipse, Gel, and Emacs."
  • URL: pmd.sourceforge.net
  • You can find a good article by Levent Gurses about PMD at Improving Code Quality with PMD and Eclipse. Altho this specifically describes the Eclips plugin, most of it applies equally well to other ways to use it, eg, the NetBeans plugin.
  • Tom Copeland, author or PMD, has a book, PMD Applied, which is described as "an easy-to-use guide for developers".
Checkstyle
Checks style for adherence to coding standards, eg, Sun. I've used it as a jEdit plugin. One nice feature is that it nags about providing javadoc comments.
URL: checkstyle.sourceforge.net/
FindBugs
Looks for bugs in Java code. Open-source, free. There's an article on its use at FindBugs, Part 1: Improve the quality of your code.
URL: findbugs.sourceforge.net
Java Coding Standard Checker
From Cafe au Lait Java News site: "Ralph Jocham's posted version 0.95 of JCSC (Java Coding Standard Checker), a configurable tool for checking Java source code for adherence to standard conding conventions such as naming conventions, code structure, class size, and line length. According to Rocham, version 0.95 "has been completely refactored. The core is now XML driven which makes the adding of further rules faster. Also, rules can be en-/disabled on a case by case basis and each rule can have a priority assigned. The priority can be used to group the parse results. These changes are reflected in an improved UI -- both in the ruleseditor and the generated XML/HTML documents. JCSC now supports CruiseControl2. This release also includes various bug fixes."
URL: jcsc.sourceforge.net
Jalopy
Source code formatter. Very active support and available as plugin in many IDEs. Check out this short article on Jalopy. There is now a $40 successor to Jalopy.
URL: jalopy.sourceforge.net/
JLint
Description: Checks Java programs for errors. Basis for CodeLint jEdit plugin. Looks for a limited number of errors in source or class files. Not very useful when I tried it.
URL: http://artho.com/jlint/index.shtml
Articles