Having 2 bare console Java applications running on the same machine at the same time I want to have, for example, something like a friend.println(String s) im my first app causing the second app to output s to its stdout (while there is to be silence in the first app stdout).
How to implement this?
You have to pass a message between the two somehow. Since they won’t both be running inside the same JVM, you have to use a communication medium that can talk between separate processes on a machine.
You could:
app2monitor a file thatapp1writes to, and react to any new entries in that fileapp2make a network socket available to receive communication fromapp1(via connecting tolocalhost)Which one you choose really depends on what you want to accomplish, and how complex you need it to be. There are pros/cons to each approach. Some of the concurrent/file-based options might produce deadlocks, for example, but any one of those choices should provide a viable method for accomplishing what you describe. The learning curves on these technologies aren’t too difficult if there are some you’re not familiar with.