|
Java Service Launcher (for Windows) JSL 0.99m - June 2011 Download here or contact the author at Michael@Roeschter.com |
@SourceForge JSL Home JSL Summary JSL Files |
Home |
Links |
Current Release |
Sample configuration file |
Change
log and archive |
Support |
Requirements |
How to |
Examples |
FAQ |
License |
Contact |
How To start my java programm as a service Quick start:
The jsl executable will look for an ini file with the same name as the executable in it's directory. Copy both to a location of your choice (possibly where your java app is located). Initialization file: Command line options -install Install the service in the NT service manager. Service is not started
immediately, though it will start automatically when NT is rebooted. -configure -remove Remove an installed service. This may fail if the service is still
running. -debug Run the application from command line for debugging purposes. Service need no be installed. You can simulate and test service stop, pause and continue behavior on the command line by starting with -debug option. Use CTRL-C for stop service, CTRL-BREAK will toggle between pause and continue service. -run Run the application from command line purposes. No -Dservice parameters will be passed. Stopping a service stopclass=java/lang/SystemAs you see above the simplest (and the default) is to call System.exit(0). If you want to do some shutdown install a shutdown hook in the JVM or simple call some other static method of your own design. Just don't forget to actually call System.exit() in the end else JSL and the Service Manager will be confused and might not report the sevice as stopped. B) The former and now deprecated way is to open a TPC/IP connection on the port specified as "stopport" in the service ini file. The most simple way to take advantage of this feature is to use the ServiceStopper class and Stopable interface as presented in the TelnetEcho example. The ServiceStopper will only accept connections from the localhost, so your service cannot be shutdown remotely. You can avoid implementing the Stopable interface by using the class SimpleStopper. This is the most simple service which simple does nothing until stopped. public static main (String[] argv) If the functionality supplied by ServiceStopper is insufficient
for your needs, you might want to implement your own handler code for stopping
the service. The port is passed to the java application via a -Dservice.stop.port=<PORT>
parameter which is prepended to the parameters given in the INI file. You
can read it back by a call to System.getProperty( "service.stop.port" ) |