Java – Run multiple java main classes at once in netbeans

class, java, main, netbeans, run-configuration

I have several main classes with different arguments. I also added the arguments to each class successfully.

But the problem is: I have to start each class manually every time (e.g. click on Run-File).

Is there a solution where I can start all the classes with one click in netbeans? And the classes should also follow a specific order.

Best Solution

  1. Open a new project with a specific name (File -> New project and complete the walk-thru) in NetBeans.

  2. You can create any number of new classes under one project by going to File -> New File -> and completing the walk-thru. At this point of time you should not include main method in these classes. Do not open a new project each time.

  3. Create yet another file (by going thru File -> New File etc.). This time in this new class include code for the main method. From the main method you can call any number of classes by creating instances of those classes. The classes will be executed in the order you called them under the main method as long as all those classes are included in the same folder, that is under the same project.

It looks like you are writing java programs just as do it in the procedural languages. To some extent java classes are like subroutines of the procedural languages. Calling them is done by creating an instance of that class.