I’m currently writing a program and I was wondering if it’s possible for eclipse to open up separate consoles automatically for each main when I run the following main method:
public static void main(String[] args) {
object1.main(args);
object2.main(args);
object3.main(args);
object4.main(args);
}
My current solution is to run each main method and select the appropriate one to view within the “Display Selected Consoles” option although it’s a very tedious process everytime I want to test my program out. I’d be very grateful for any suggestions you have.
Thanks
If you do multiple calls to your
mainmethod from within anothermainmethod, this will not be different from calling any other static method multiple times. Particularly, all those instances of your program will be executed in the same JVM.Instead, you could use a simple Ant script to start multiple instances of your program, for example:
This script defines three targets — which of them is executed is determined in the
defaultparameter.compile, just invokesjavacto build all the sources in thesrcdirectory. This is automatically executed before any of the other targets are run.run_many, simply starts your Main class several times in parallel. Each instance will run in a separate JVM, but the output of all those instances will be mixed up in Eclipse’s console window.run_external, starts anxtermterminal emulator running the respective Java processes, i.e. for each instance of your program a new terminal should pop up. (When doing this on Windows you may have to usecmd.exeor similar.)Not sure whether this is what you were looking for. Hope this helps.