<p>I would like to implement a command line interface for a Java application. This wouldn't be too difficult to do, except I would like the command line program to affect the state of another Java GUI program. So for example, I could type:</p>

<pre><code>java CliMain arg1 arg2
</code></pre>

<p>And another running GUI instance would perform an appropriate action.</p>

<p>What is the easiest way of implementing something like this?</p>

You could have the GUI application listen on a TCP port (on the
```
localhost
```
interface) and the CLI application would connect to it.
One way to do this would be to use REST over HTTP.