Natalia
Natalia

Reputation: 783

Java service with GUI tool

I have an application with GUI. GUI is used for settings management only. Now I need to turn this into Windows service. I thought of splitting my app into 2: service itself and GUI-tool for providing settings. Main problem is that I'm not sure, how this tools should "communicate". Settings are stored mostly in files, and after new settings applied, service should restart.
As for now, I thought of admin-tool sending few requests to service over TCP/IP, that also allows to control service from the network. Problem is that I need to hardcode, or use some text file, to set default port on which service would listen for admin-tool connections after it's installation.
May be there is any alternative solution, which is more suitable here?

Upvotes: 1

Views: 991

Answers (1)

user890904
user890904

Reputation:

You are creating a service. If all you need in the communication layer is being able to stop and start the services, then you don't need to open a port and start listening. The system gives you means to do that with commands that you can run. you are talking about windows, so for example you can run the command "sc start MyServiceName" to start service "MyServiceName". there is also a command called "net" which allows you to start and stop services. These OS commands can be then called from java code in various ways that are available to execute external code.

here is a link that shows how to do that with sc command, check the accepted answer: start-windows-service-from-java

here is another link that shows difference between two commands "sc" and "net": net-start-service-and-sc-start-what-is-the-difference

Note that "sc" supports starting services on remote machines: simplest-way-to-restart-service-on-a-remote-computer

Upvotes: 2

Related Questions