title: "The public type <<classname>> must be defined in its own file" error in Eclipse
body: <p>I have written the following code:</p>
  
  <pre><code>package staticshow;
  
  
  public class StaticDemo {
    static int a = 3;
    static int b = 4;
  
    static {
      System.out.println("Voila! Static block put into action");
    }
  
    static void show() {
      System.out.println("a= " + a);
      System.out.println("b= " + b);
    }
  }
  
  public class StaticDemoShow {
    public static void main() {
      StaticDemo.show(); 
    }
  }
  </code></pre>
  
  <p>I am getting the error message:</p>
  
  <pre><code>The public type StaticDemo must be defined in its own file
  </code></pre>
  
  <p>error in the very first line <code>public class StaticDemo {</code>. Why is it happening and how can I resolve it? Note that my project name is <code>StaticDemoShow</code>, package name is <code>staticshow</code> and class names are as given in the code.</p>
  
  <p><strong>EDIT</strong>- After making just one class public or both the classes default, I am getting the error "Selection does not contain a main type". Now what should I do?</p>