title: Import .java Files Into the Correct Package
body: <p>I have a bunch of <code>*.java</code> source files that contain classes in various packages. I am trying to import all of these files into Eclipse projects, but Eclipse always places them in the default package.</p>
  
  <p><strong>How can I tell Eclipse to place each of the files in the appropriate package subdirectory, so I don't have to create all the various packages manually?</strong></p>
  
  <p>I have tried the <em>import from file system</em> feature as well as copying the files into the project, all of which would place the files in the <code>default</code> package rather than those ecplicitly stated in the <code>package</code> statement on top of each file.</p>
  
  <p>Related SO questions only deal with <a href="https://stackoverflow.com/questions/10910160/source-folder-is-not-on-the-java-build-class-path-creating-java-package">referencing packages outside of the project's <code>src</code> directory hierarchy</a>, <a href="https://stackoverflow.com/questions/6997524/the-declared-package-does-not-match-the-expected-package">manually creating files in the suitable package directory</a>, <a href="https://stackoverflow.com/questions/2681161/how-to-import-a-package-from-eclipse">missing <code>import</code> statements</a>, or <a href="https://stackoverflow.com/questions/11047841/how-to-add-prefix-to-package-names">bulk-renaming packages</a>, but it doesn't seem like this problem has already been discussed.</p>
  
  <p><strong>Update:</strong> As requested in the comments, here are some example files:</p>
  
  <p>Test1.java</p>
  
  <pre><code>package some.random.pkg;
  
  public class Test1 {
  }
  </code></pre>
  
  <p>Test2.java</p>
  
  <pre><code>package some.other.pkg;
  
  public class Test2 {
  }
  </code></pre>
  
  <p>Test3.java</p>
  
  <pre><code>package yet.another.pkg;
  
  public class Test3 {
  }
  </code></pre>
  
  <p>Place all of them in the same directory, then try to import them into a Java project in Eclipse without manually creating the directories for the various packages.</p>
  
  <p><strong>Update 2:</strong> In order to clarify the scale, assume that there are actually approximately 100 files like these (of course, with more contents ;-) ) on a weekly basis, which is why I'm looking for an automated solution.</p>