Java/Tip & Tech2009. 4. 3. 11:02

Command Summary

The commands listed below are self-documented within the application, if invoked from a Windows command prompt with the JavaService -help command.

 

-help

(or -?) Lists the commands available from JavaService

 

-version

Outputs the built-in version number of the JavaService program

 

-license

(or -licence) Outputs the LGPL licensing text covering the program

 

-install servicename

Installs the named service with specified configuration options

 

-queryconfig servicename

(or -query) Displays confguration details for the installed Java service

 

-status servicename

Displays current execution status of the named Java service

 

-uninstall servicename

Removes definition of the specified Java service

 

 

Available Operations

Service Installation

The main command function needed from JavaService is the ability to install a Java application as a Windows system service.

 

From a Windows command prompt, or a suitably defined script file, enter the command:

JavaService -install

Followed by the relevant parameters as described below. Ensure that quotation marks are used around an parameters that contain spaces to avoid run-time failures.

 

service_name (mandatory) - The name that you want to use for this service. This is what the service will show up as in the service control manager.

 

jvm_library (mandatory) - The location of the jvm.dll file that you want to use as your Java Virtual Machine. For Sun's Java 2 SDK, this is usually {JDK_HOME}\jre\bin\classic\jvm.dll or {JDK_HOME}\jre\bin\hotspot\jvm.dll.

 

jvm_option* (optional) - To specify any parameters to pass to the JVM upon invocation. These may include things such as "-Djava.class.path=" to specify a classpath or "-Xmx128m" to specify a maximum heap size of 128MB. Any parameters that you need to use when invoking the java.exe command tool should be specified here. There is no fixed limit to the number of parameters specified.

 

-start start_class (mandatory) - The name of the class that you wish to use when starting the service. This must be the fully qualified class name.

 

-method start_method (optional) - The name of the static method of the start_class that you wish to call to start the service. The method must be static, must return type void, and must take a String[] as its only parameter. If this parameter is not specified it defaults to main.

 

-params start_parameter+ (optional) - Any parameters to pass to the start_method when starting the service. These will be passed in as the String[] parameter.

 

-stop stop_class (optional) - The name of the class that you wish to use when stopping the service. This must be the fully qualified class name. If no stop_class is specified, the process containing the Virtual Machine is simply terminated when the service is stopped.

 

-method stop_method (optional, but only allowed if a stop_class was specified) - The name of the static method of the stop_class that you wish to call to stop the service. The method must be static, must return type void, and must take a String[] as its only parameter. If this parameter is not specified it defaults to main.

 

-params start_parameter+ (optional, but only allowed if a stop_class was specified) - Any parameters to pass to the stop_method when stopping the service. These will be passed in as the String[] parameter.

 

-out out_log_file (optional) - A file into which System.out will be redirected. If this parameter is not specified, System.out will not be redirected.

 

-err err_log_file (optional) - A file into which System.err will be redirected. If this parameter is not specified, System.err will not be redirected.

 

-current current_dir (optional) - A directory to use as the current working directory for the service. If this parameter is specified, all relative paths in the service will be relative to relative to the specified directory.

 

-path extra_path (optional) - An addition to the path for the service. The specified path will be appended to the system path before the service is started. This can be used to specify where additional DLLs that native libraries are dependent upon can be found.

 

-depends other_services (optional) - Another NT service (or multiple services, if specified as a comma-separated list) that must be running before this particular java service can start. Will cause the named service(s) to be started automatically if required when starting the java service. Will also stop the java service if a specified service is stopped (usually with user confirmation first being requested by Windows NT).

 

-auto or -manual - Optional parameter indicating whether service should be run automatically on system startup (default mode), or if it should be started on demand using a manual command (i.e. net start service).

 

-shutdown seconds (optional) - Specify the amount of time that may be taken during processing of your shutdown/stop method. The value here is used as a timeout, so if the method has not completed in this length of time, the JVM process will be terminated to allow the service to shutdown completely.

 

-user user_name (optional) - Specify the Windows domain username to be used when running the service (also requires that the password parameter is specified).

Local user accounts are specified as .\user_name whereas domain accounts may be specified as either domain\user_name or user_name@domain (the latter form has been required on some systems to avoid reports of 'I/O Operation in progress' errors).

 

-password password (optional) - Specify the Windows password associated with the domain username specified for use when running the service (required if the user parameter is specified).

 

-append or -overwrite - Optional parameter indicating whether output and error log files are to be appended to, or overwritten, on each service startup. If not specified, the default is to append to existing log files.

 

-description service_desc - Optional parameter indicating descriptive text to be recorded against the service when installed. Use "quote characters" for text that includes spaces. Note that this function is only supported when used from Windows NT Version 5 or later (Windows 2000, Windows XP, etc).

 

 

Removing a Service

JavaService provides a command to enable configuration of a Java service to be correctly removed from the system.

 

From a Windows command prompt, or a suitably defined script file, enter the command:

JavaService -uninstall service_name

Where:

 

service_name (mandatory) - The name of the service that is to be removed.

출처 : http://forge.objectweb.org/projects/javaservice/

Posted by Huikyun