SourceForge Logo

ImportScrubber - clean up those import statements!

Before After

import javax.swing.*;
import javax.swing.JLabel;
import java.lang.Integer;
import java.awt.*;
import java.awt.Frame;


import javax.swing.JLabel;
import javax.swing.JOptionPane;


No more unnecessary imports, no more import on demand - just good old single type imports. And they're sorted, too!

You can download ImportScrubber, check out a screenshot, see how to use ImportScrubber's Ant task, or read about Importscrubber's current limitations. If you've installed Java Web Start, you can run ImportScrubber as a JNLP application. You can also mosey over to the Jakarta web site where parts of ImportScrubber are being using in Maven.

Thanks to Sourceforge for hosting this project. Thanks to Poolmart for letting me use a picture of one of their scrub brushes. Thanks to Markus Dahm, writer of BCEL, which I use for parsing class files.


Jonathan Ellis
Rewrote most of Importscrubber for 1.4.3.
Toshiyuki Iwata
Contributed a file encoding option patch.
Neil Wightman
Contributed all of the new code in 1.4.2 - lots of GUI cleanups and threading improvements.
Roedy Green
Pointed out "val." imports bug.
Stefan Kost
Notified me about v1.4.0 bug (the same bug that Marcus Crafter found).
Marcus Crafter
Provided a shell script, suggested a "space vs tab" bugfix (v1.4.0)
Found a heinous bug in 1.4.0.
Martin Saxer
Rewrote the import statement sorting logic to keep packages together (v1.3.9)
Provided a French translation (v1.3.9)
Mark Langley
Suggested that fully qualified imports not be included in the import statement list (v1.3.9)
Jason Van Zyl
Tweaked copyright header preservation feature (v1.3.5, v1.3.6)
Reported static class bug (v1.3.8)
Marcus Dahm
Suggested some changes to the way ConstantUtf8 class file entries were being analyzed (v1.3.7).
Scott Willy
Contributed the DualRootSingleFileChooser (v1.3.3)
Suggested the copyright header preservation feature (v1.3.4)
Trent Hoeppner
Found several bugs in v1.3 scripts
Suggested the copyright header preservation feature (v1.3.4)
Uwe Hoffman
Suggested using the BCEL Visitor when parsing class files. Identified constant bug.
Dan Bromberg
Suggested file browser open to a more useful directory (v1.2.2)
Channing Walton :
Suggested package break feature that was implemented in v1.2 and tweaked in v1.2.2.
Fine-tuned package break feature in v1.1.6
Package break feature in v1.1.4
Paul Holser
Identified java.lang bug that was fixed in v1.1.9.
Identified "import class." bug that was fixed in v1.1.8
Fixed java.lang subpackage filtering bug for v1.1.7.
Brad Johnson
Reported static inner class bug which was fixed in v1.1.6 (later reported by Paul Holser and Channing Walton)

Related projects

CleanImports by Tom Brus - a good one. Lots of options. Uses BCEL.
ImportCleaner by Cay Horstman - very fast, parses class files using a handwritten parser. Suffers the same constant inlining woes as ImportScrubber.
Importscrubber by Joshua Allen - uses a neat strategy of Class.forName'ing any candidate imports.
Importifier by Scott Stanchfield - runs inside IBM's VisualAge IDE.
TIM by Chive Software - commercial product.

Any comments or questions, please let us know. Thanks!