title: Eclipse is confused by imports ("accessible from more than one module")
body: <p>When referencing simple .jar files, Eclipse shows an error stating:</p>
  
  <blockquote>
    <p>The package java.awt is accessible from more than one module: &lt;unnamed&gt;, java.desktop</p>
  </blockquote>
  
  <p>This happens for instance when <code>javax.awt</code> or <code>javax.swing</code> is included in the .jar files.</p>
  
  <p>The simplest example would be the following:</p>
  
  <pre><code>package test;
  
  import javax.swing.JDialog;
  
  public class Test {
      public static void main(String[] args) {
          new JDialog();
      }
  }
  </code></pre>
  
  <p>Adding a .jar file to the classpath with only the folder structure <code>javax/swing</code> (no files needed) will cause the error to appear. I'm using JDK 10/12 (neither works). Setting the compiler compliance to <code>1.8</code> makes the whole thing work again.
  On another machine with <code>Eclipse 2018-09</code> this works with compiler compliance set to <code>10</code>.</p>
  
  <p>I'm on Eclipse <code>2019-03</code>, on a (for testing purposes) freshly installed <code>Eclipse 2018-09</code> it works fine. Why?</p>
  
  <p><strong>Edit June/2020 (Solution)</strong></p>
  
  <p>As the answers correctly stated, this is a restriction built into Java ages ago and only recently was forced upon us. I came into contact with it while migrating a big project with dozens of dependencies to Maven. There were libraries from around the year 2000! There were 'meta libraries' which consisted of several libraries packaged together.
  So there was no other way than to identify what was still needed (into the trash with the rest!), update libraries which violate the rules or find replacements for them. This took me many, many hours.</p>
  
  <p>In the end it worked out and we've got a nice Maven project to work with.</p>