import tidier : Java Glossary
- import tidier
aka import scrubber. A program that tidies the import statements in a program by:
- Sorting the imports and gathering the imports into groups for java and user classes.
Existing Import Tidiers
- The Joshua Allen import scrubber uses the classpath and does a Class.forName to
make sure each class imported really does exist. It is written in pure Java. Its main limitation is it must run
with the same classpath as the project you are tidying. This what I use myself. Joshua seems to have
disappeared. I could email you the jar. It occasionally discards imports incorrectly, mainly when you are in
package aaa.bbb.c and import from package aa.bbb.c.
And of course it is no longer being maintained, but I have used it successfully for many years.
- Sourceforge Import Scrubber: It
lacks documentation and installation instructions as is typical of opensource projects by and for geeks.
- Scott Stanchfield had started working on an importifier for Visual Age. He is willing to share
his source code.
- Tom Copeland wrote Import Scrubber as a Java Web Start weblet. It
currently offers you only a few options. It always expands wildcards. It often prunes a few too many imports
making your source no longer compile. It cannot see the all the references the class files to imported packages
unless you compile with the -g (generate debugging) option. It drops some even if you do, (if you use
any qualification anywhere for a class) so make backups first. You can also download it as conventional app with source. It does not look at
the classpath so it does not validate that any of the classes actually exist.
- The Eclipse IDE (Integrated Development Environment) has a built-in import scrubber.Click Navigate ⇒ show in ⇒ Package Explorer (if not already there) ⇒ select the tree you
want to tidy ⇒ right click ⇒ source ⇒ organize imports. You might as a well to a format
to pretty the files while you are there.