How do I automatically set my imports?
Author: Deron Eriksson
Description: This tutorial describes how to automatically set the imports in a .java file.
Tutorial created using: Windows XP || JDK 1.5.0_09 || Eclipse Web Tools Platform 2.0 (Eclipse 3.3.0)
EclipseSW has a very handy "Organize Imports" feature that will automatically add the correct imports to your .java files. As an example, suppose we created an OrganizeImportsTest class, shown below. This class has Properties and Enumeration classes, which are not recognized initially, as indicated by the red underlines.
'Organize Imports' will automatically add the necessary imports to the top of your .java file. Here, you can see that java.util.Enumeration and java.util.Properties were added as imports.
If Eclipse finds that more than one class can resolve to a particular class, a pop-up window will appear to let you select the correct class.