title: Eclipse on Windows cannot resolve java.util.Comparator
body: <p>I'm not familiar with Java or Eclipse. There's a java program with several imports that I want to run. I created a new project in Eclipse and pasted in the code, but it draws a red line under java.util.Comparator and says it cannot be resolved. All other imports work.</p>
  
  <p>Confused, I downloaded the latest version of Eclipse and overwrote the previous version, but problem still exists. I wrote a HelloWorld program and it works.</p>
  
  <p>Here is a code sample to reproduce the problem:</p>
  
  <pre><code>import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileOutputStream;
  import java.io.InputStreamReader;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Comparator; // error: The import java.util.Comparator cannot be resolved
  import java.util.HashMap;
  import java.util.Iterator;
  
  public class MyClass
  {
      class MyComparator implements Comparator // error: Comparator cannot be resolved to a type
      {
          public int compare(Object arg0, Object arg1)
          {
              ArrayList&lt;String&gt; ap0 = (ArrayList&lt;String&gt;) arg0;
              ArrayList&lt;String&gt; ap1 = (ArrayList&lt;String&gt;) arg1;
              return ap0.size() - ap1.size();
          }
      }
  
      void work()
      {
          ArrayList&lt;ArrayList&lt;String&gt;&gt; list = new ArrayList&lt;ArrayList&lt;String&gt;&gt;();
          Collections.sort(list, new MyComparator()); // error: The method sort(List&lt;T&gt;, Comparator&lt;? super T&gt;) from the type Collections refers to the missing type Comparator
      }
  }
  </code></pre>
  
  <p>The compiler (or builder?) also says: 
  The project was not built since its build path is incomplete. Cannot find the class file for java.util.Comparator. Fix the build path then try building this project</p>
  
  <p>Suggestions?</p>