title: How to run two classes at a time in CMD in Java
body: <p>Hello I create one java file which contains two classes <strong>TwoClass</strong> and <strong>TwoClass2</strong> On compilation it gives me two class files separately but I have to run each class file separately.. How can I do this ? My code is as follows: I saved this file as <strong>TwoClass.java</strong></p>
  
  <pre><code>class TwoClass{
  public static void main(String args[])
  {
      System.out.println("I am first class");
  }}class TwoClass2{
  public static void main(String args[])
  {
      System.out.println("I am Second class");
  }}
  </code></pre>
  
  <p>After compilation it generates <strong>TwoClass.class</strong> and <strong>TwoClass2.class</strong> Now if I want to run this files I do as follows: </p>
  
  <blockquote>
    <p>G:\ZPREP>javac TwoClass.java</p>
    
    <p>G:\ZPREP>java TwoClass
    I am first class</p>
    
    <p>G:\ZPREP>java TwoClass2
    I am Second class</p>
    
    <p>G:\ZPREP></p>
  </blockquote>
  
  <p>There is no problem here at all but I have to run each file separately so any thing is their to run both files at a time ??? Please help.</p>