title: Java Error: When Calling a Different Class in the Main method but Runs Fine when compiled same class with the main method
body: <p>I am trying to compile this code on CMD.</p>
  <pre><code>public class Main {
  
      public static void main(String[] args){
          new HelloWorld(&quot;Main Window&quot;);
      }
  }
  </code></pre>
  <p>this is the HelloWorld class</p>
  <pre><code>import javax.swing.JFrame;
  
  public class HelloWorld extends JFrame{
  
      public HelloWorld(String title){
          super(title);
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          setVisible(true);
       }
  }
  </code></pre>
  <p>but it is giving me an error like
  <a href="https://i.stack.imgur.com/gHfQY.jpg" rel="nofollow noreferrer">CMD snap shot</a></p>
  <p>but when I instantiate HelloWorld in the same class with the main method, it runs fine.</p>