Julia
Julia

Reputation: 52

how do i to run multiple java programs/classes from the command line at the same time (or is it not possible)?

I noticed that I could compile multiple java programs/classes from the command line at the same time. Here's how I did it (they have to be in the same folder/location):

  1. open command prompt
  2. locate file
  3. type "javac filename1.java filename2.java filename3.java..."

Is it possible to run them at the same time too? I've tried to do this multiple times, but it just doesn't seem to work. Either I get an error message, or the program fails to run.

Any Suggestions?

Upvotes: 0

Views: 3900

Answers (1)

emory
emory

Reputation: 10891

Yes it is possible to run multiple java programs simultaneously. One way is to create a java program like so

class Main{
     public static void main(String[]args){
          new Thread(){
               @Override
               public void run(){
                       NameOfFirstJavaAppClass.main(fill,in,the,args);
               }
          }.start();
          new Thread(){
               @Override
               public void run(){
                       NameOfSecondJavaAppClass.main(fill,in,the,args);
               }
          }.start();
     }
}

Upvotes: 4

Related Questions