title: Main method not found error Java
body: <p>I am trying to run the simple word count program below in Eclipse and i am getting a error .I have checked my configurations in Run As and they are correct</p>
  
  <pre><code>Error: Main method not found in class wordcount.WordCount, please define the main method as:
     public static void main(String[] args)
  or a JavaFX application class must extend javafx.application.Application
  </code></pre>
  
  <p>Here is the program </p>
  
  <p>package wordcount;</p>
  
  <pre><code>import java.io.*;
  import java.util.*;
  
  // This program does word-counting on the text of Moby Dick.
  public class WordCount {
    public static void main(String[] args) throws FileNotFoundException {
      HashMap map = new HashMap();  // word --&gt; # of occurrences
  
      // read each word from the file
      Scanner in = new Scanner(new File("mobydick.txt"));
      while (in.hasNext()) {
        String word = in.next();
  
        if(map.containsKey(word)) {
          // if we have already seen this word before,
          // increment its count by one
          Integer count = (Integer)map.get(word);
          map.put(word, new Integer(count.intValue() + 1));
        } else {
          // we haven't seen this word, so add it with count of 1
          map.put(word, new Integer(1));
        }
      }
  
      // now print out every word in the book, along with its count,
      // in alphabetical order
      ArrayList arraylist = new ArrayList(map.keySet());
      Collections.sort(arraylist);
  
      for (int i = 0; i &lt; arraylist.size(); i++) {
        String key = (String)arraylist.get(i);
        Integer count = (Integer)map.get(key);
        System.out.println(key + " --&gt; " + count);
      }
  
    }
  }
  </code></pre>