-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

3
  • What is mainMethodArgument? Can you paste its value? Commented Sep 1, 2016 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 Commented Sep 1, 2016 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 Commented Sep 2, 2016 at 10:25

1 Answer 1

-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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.