Using Eclipse Organized Imports Without Annoying Others

I found a neat little trick in Eclipse 3.3 which will keep my TextMate-using coworkers happier with me.

Eclipse' Organize Imports (Ctrl-Shift-O) is handy for quickly finding and adding an import for a class you just started using in your code, but the default behavior is to list out each class in a long list of explicit imports. Users of text editors may hate you for always replacing their import java.util.*; with your convenient little keystrokes.

Wildcard imports can be accomodated and generated from Eclipse by changing a preference. Open Window menu -> Preferences window -> Java -> -> Code Style -> Organize Imports and change the Number of imports needed for .* options down to 1. Then importing just one class from a package will result in an import package.*;, which your project mates may appreciate more.


Filed Under: Java Computers Work