-1

I have a java class with a main method . I converted it into a windows service using Java Service Wrapper from tanuki software . I then tried to start the service programmatically from another java program by using ProcessBuilder.

ProcessBuilder processBuilder = new ProcessBuilder("cmd.exe", "/c", "sc",     "start", serviceName,mainMethodArgument);

Process process=processBuilder.start();

The service is getting started alright . But the command line argument that i passed ( mainMethodArgument ) is not getting to the service main method . What am i doing wrong? I need to send only a single startup parameter. But still it is not getting through

Vivek
  • 341
  • 1
  • 5
  • 15
  • What is `mainMethodArgument`? Can you paste its value? – Tunaki Sep 01 '16 at 13:27
  • @Tunaki: mainMethodArgument could be anything. For eg: i tested with "blah" . Then in the service main method i tried to take it as args[0] , but in no vain – Vivek Sep 01 '16 at 13:30
  • This is not duplicate of the, I guess you are not aware or don't know the difference b/w starting the windows service and running a exe – jan_kiran Sep 02 '16 at 10:25

1 Answers1

-1

I don't think so you can pass parameters dynamically to the service. Check this link https://wrapper.tanukisoftware.com/doc/english/prop-app-parameter-n.html. Probably you can write the parameters to a file which can be configured in the wrapper.conf file and then read the content in you startstop or main based on your implementation of tanuki

jan_kiran
  • 301
  • 3
  • 16