title: Automatically remove explicit package declarations with import statements in Java
body: <p>I have a project created by others that includes thousands of class files and has the package names explicitly typed out for every reference to any of their classes. It looks like the code was reverse engineered. Is there a good tool for Java that refactors the code so that the explicitly typed package prefixes are removed from class references and moved into import statements.</p>
  
  <p>Thank you in advance.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I think an example will help. I want to have the imports at the top, and I don't care how many imports there are.</p>
  
  <pre><code>javax.swing.JButton button1 = new javax.swing.JButton();
  </code></pre>
  
  <p>Imagine the code above but absolutely everywhere in thousands upon thousands of lines of code amongst thousands of class files. I would like to be able to remove all of the prefixes and just have a nice import javax.swing.JButton; at the top of each class file.</p>