I have a small Java console application that runs a set of data through an algorithm. Given the size of the data and compute time, I often run 10 to 15 instances of the application, each working on a subset of the data.

All that is behaving ok. The application occasionally prints a sysout for my information. Rather than monitoring up to 15 console windows, I'd like all the sysouts to be displayed in a separate 'monitor' window. So instead of a sysout, each application would have something like

monitor.sendMessage("blah blah");

which would invoke a method on the monitor app.

I'm unsure how to do this because each console is a separate instance of the app. I assume I'd need to create a second app, but then I don't know how to invoke it and pass a message to it from the other applications. Remember this second monitoring app must be in a separate console window.

All this is happening locally so I'd rather avoid any solutions that use HTTP or complex networking protocols if possible

Finally it would be very desirable to be able to have two way communication i.e the monitor app could also invoke a method in the other apps.

  • Have you considered Java RMI yet? In modern Java versions (6 and newer) it is fairly seamless and easy to use. It can be used for applications running anywhere, even on the same host. It is also built-in to the core Java libraries.
    – user22815
    Commented Apr 13, 2016 at 5:11
  • You have a bunch of processes that you want to be able to communicate with. In the software world that is called "Interprocess Communication". There are dozens of ways to accomplish what you want, many of which are language/operating system dependent and some are fairly generic that you can use on most any platform. If you are a software developer worth paying a salary to at all then you should be intimately familiar with at least 3 or 4 of those ways. Rather than have someone tell you a specific way, you really should go read up and learn about "Interprocess Communications".
    – Dunk
    Commented May 13, 2016 at 17:51

2 Answers 2


Is it possible to change the design a bit as suggested by me ?

Use a common log file for all processes. You can read the log by a seperate application and display whatever is necessary based on filters. Make sure that you log everything in a transaction ( think synchronized but for multiple processes) . Otherwisse multiple processes writing will garble log messages.

Also instead of invoking something directly in the first app , can the app which is reading log send a message to the first app ( can be through JMS or just simple files. Be sure to clean it up every time though ). As soon as something is detected , it creates a file(s) in a pre determined directory. Thread in first app waits for any files in directory and processes it. You will have to have convention as to which app reads this message as you said you run 10-15 apps.

You might have also to go the multi threaded way to enhance the communication between threads using notify/interrupt etc instead of processes.


Why not just fork/exec these processes from a main (parent) process (using Runtime.process())?

That way your parent process spawns off 'n' subprocesses. By necessity your parent process has to read the stdout/stderr of your child processes, and you can consolidate and display that info per process (since each spawned process will have its own output stream). Your child processes can read their stdin (input console stream), and the parent process can write commands down that stream to each child process.

As a point of reference, I'm doing this right now for a client. I run my parent process (using a --parent argument), and that forks off multiple child processes (running the same code base but with a --child argument, thus invoking different code). I feed commands in via stdin and capture the logs via the child process stdout/err and report those. Because each child has a different reading thread I can identify trivially which child process is issuing which output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.