javasvc
javasvc is a Windows application that manages any Java application, and installs it as a Windows service. Unlike other similar utilities, javasvc is simple in that there are no configuration files, coding requirements, etc., and it's free.
You only need to have one instance of javasvc on your system. A good place to copy the file is the System32 directory, as that is usually pathed and can be called from anywhere. Note that javasvc is sensitive to where it is called from, as that is stored as the working directory when it runs. In essence, think of "javasvc" as the same as "java".
javasvc syntax:
javasvc [/?|/i|/r|/u] <Service Name> <Arguments>
Switches
- /? - Pops up a help window with instructions
- /i - Installs the service
- /r - Never should be used by a user! - Called by the Windows NT Service Control Manager
- /u - Uninstalls the service
/i Switch
The /i switch installs the service. It takes a minimum of two arguments, the service name, and the command that should be called. If there are spaces or funny characters, then place quotes around the arguments.
Syntax:
javasvc /i [/dep=<Dependency Service>] [/des=<Description>] <Service Name> <Command Arguments>
Example:
C:\MyDirectory> javasvc /i "MyService" "java -classpath abc.jar myclass"
Will install a service called "MyService". When this service is started, using say "net start MyService" it will run "java -classpath abc.jar myclass" from the directory MyDirectory
C:\MyDirectory> javasvc /i /dep="Alerter" /des="My Service is Cool" "MyService" "java -classpath abc.jar myclass"
Will install "MyService", adding the Windows "Alerter" Service as a dependency (meaning Alerter will be started BEFORE MyService is started). Additionally, "My Service is Cool" will appear in the description field of the service in the Services Control Panel.
/u Switch
Uninstalls the service.
Example:
javasvc /u "MyService"
Will uninstall the service "MyService". Note that for uninstall, the directory is not relevant as it is for the install switch.
Download javasvc.exe (~ 75KB)