I would like your tipps about implemening a command line interface to interact with a running java application.


The Java Application is a webserver and a cli-client should interact with it:

1 ) Start server application: java -jar webserver.jar

2) Get status of the running application: java -jar webserver.jar --status or other commands like: java -jar webserver.jar --add-user Paule --password 1234 so adding an entry in a hashmap in the running application.

Does anyone know a Best-Practice tutorial about this?

Implementing a HTTP/TCP/UDP/UNIX-Socket would be one solution for interaction.

An other solution would be reading external resources and placing commands in a file for example.

What is your way to implement this?

Is there a technical term for interaction with a running thread?

Thanks in Advance

closed as too broad by gnat, Martin Maat, Bart van Ingen Schenau, Jörg W Mittag, Laiv Jan 7 at 8:31

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
  • Thanks. RMI (Remote Method Invocation), SOAP(Simple Object Access Protocol) and JMS (Java Message Service) are too complex for my application. A simple pure java solution for sending a string (being interpreted as command) to a running app would be sufficient. – User8461 Jan 6 at 1:24
  • In case you end up expanding on your cli and want a good framework for them, I highly recommend pico cli – J Lewis Jan 7 at 9:37

I would use a TCP (or maybe UDP) connection.

The client would send commands via TCP to the server, and the server could answer (e.g. OK or NAK).

Format of the commands could be simple text strings (maybe separated with ;), XML or a binary format depending on your needs.

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