David Staas

Java Service - command-line parameters?

I have a fairly simple application that I'd like to have installed as a Java service. Here's the batch file I currently use to launch the application:

java -cp bananas.jar;hme.jar;netflixrss-1.10.jar;mjxml.jar;jaxb-api.jar;jaxb-impl.jar;jaxb-libs.jar;jaxb-xjc.jar;jax-qname.jar;namespace.jar;relaxngDatatype.jar com.tivo.hme.sdk.Factory com.bitrazor.netflixrss.NetFlixRSS

... and I want to create a 'real' installer around this and have the application run as a service. Here's the problem I'm running into:

Main() exists in com.tivo.hme.sdk.Factory, and I pass com.bitrazor.netflixrss.NetflixRSS as a parameter. My question: where do I put that parameter (the one in red)? I've tried it several places:

- in the 'Arguments' box under 'Service Parameters'
- in the 'JVM Parameters' box
- at the end of the 'Main Class' box
- in the 'Arguments' box under 'Service Context'

None of these seem to work. Under certain circumstances, I can get the install to happen successfully, and I can start the service, but when I try to run the app, it hangs (and it's the same type of behavior consistent with that last argument not being passed in properly).

Any pointers are appreciated. I have reviewed the Java tutorial, help, and poked around in the forums. TIA -- Dave
[/list]
Mike
Posts: 292
Joined: Wed Jun 01, 2005 10:50 am
Location: Craiova, Romania
Contact: Website

Hi David,

The parameters in the 'Arguments' box under 'Service Parameters' (Control Operation Parameters page) are passed only once, when the MSI is installed and the service is started for the first time.

The parameters in the 'Arguments' box under 'Service Context' are passed every time the service will start.

Be careful to specify in the 'Control Operation Parameters' window the service name that each control operation is assigned to.

Also be careful for any bugs that might be present in the code of your java application. I would suggest a "debug" version that will print the parameters that it receives.

Regards,
Mihai
Last edited by Mike on Mon Aug 15, 2005 7:35 am, edited 1 time in total.
Mihai Bobaru
Advanced Installer Team
http://www.advancedinstaller.com

Return to “Common Problems”