How to launch multiple Java programs with one configuration on separate consoles (with Eclipse)

StackOverflow https://stackoverflow.com/questions/316761

  •  11-07-2019
  •  | 
  •  

Question

I'm working with a Java program that has multiple components (with Eclipse & Ant at the moment).

Is there some way to start multiple programs with one launch configuration? I have an Ant target that does the job (launches multiple programs) but there are things I would like to do:

  • I would like to debug the programs with Eclipse, hence the need for Eclipse launch.
  • I would like to see the outputs for the programs at separate consoles.

Also other ways to launch multiple Java programs "with one click" with separate consoles and/or debugging would be ok.

Was it helpful?

Solution

['multiple launch part':]

If you have an ant launch configuration which does what you want, you can always transform it into a java launcher calling ant.

Main Class: org.apache.tools.ant.Main

-Dant.home=${resource_loc:/myPath/apache_ant} 
-f ${resource_loc:/myProject/config/myFile-ant.xml}

You can then launch this ant session as a regular java application, with all eclipse debugging facilities at your disposal.

Add to your classpath in the User Entries section (before your project and default path):

  • ant.jar
  • ant-launcher.jar

[Multiple console part]

May be a possible solution would be to make sure your ant launcher actually launches the different application in their own JVM process (one javaw.exe for each application)

That way, you could use the ability of the native eclipse console to switch between different process.

The Console view clearly separates output from each distinct "process" and keeps them in several "buffers". The Console has a built-in "switch" feature that will automatically switch the view to display the buffer of the last process that performed output, however you can easily switch the display to any "process buffer" you want to look at.

To switch the Console "buffer" display, just click on the black "Down arrow" next to the 4th toolbar button from the right in the Console View's title bar (the button that resembles a computer screen):
this will show a pop-down menu listing the "names" of all active process buffers, preceded by an "order number". The one currently displayed will have a check-mark before its "order number". You can switch the view to another display buffer simply by clicking on its name.

OTHER TIPS

The question and selected answer here are both 6 years old.

Eclipse Launch Groups provides UI to run multiple launch configs. Launch Groups is apparently part of CDT but can be installed separately without CDT by installing "C/C++ Remote Launch" (org.eclipse.cdt.launch.remote).

There's actually a ticket opened at Eclipse site which requests this very same functionality. One of the contributors there proposed a plugin which allows grouping more launch configurations (possibly of different types) and start all of them with one mouse click.

Although the plugin functionality is limited, it does a great job. Source code is included so you can make changes as necessary. You will have to open it as a PDE project in your Eclipse and export it as a JAR, then place the JAR file in your Eclipse' plugins folder. A bit cumbersome but you do this only one time. After that restart your Eclipse and look for "Basic Workflow" in your launch configurations dialog.

Plugin source is available here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=39900#attach_177951

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top