Author Topic: How to Convert a Java Program Into a Windows Service  (Read 614 times)

0 Members and 1 Guest are viewing this topic.

Offline ebenzunlimited

  • Lead Admin
  • *****
How to Convert a Java Program Into a Windows Service
« on: November 26, 2012, 08:26:01 PM »
a Faster web hosting service
Java is a widely used language in which many programs are being written. Windows is the most widely-used operating system and there are many occasions when a Java program needs to run as a windows service. This article explains how a java program can be run as a windows service. There are many libraries and programs available that can be easily used to wrap a Java program into a windows service. This article describes use of free software Java Service Launcher (for Windows) to run a Java program into a windows service.
Instructions

    Program info and getting the Service Launcer
        1

        Note down which class (say com.sample.EntryClass) in the java program is the entry point for the application and has the main method.
        2

        Note down the location of the java archive(jar file) which contains the java program.

        Sponsored Links
            Analyze C# code coverage

            View code coverage in Visual Studio Coverage highlighting and reports
            jetbrains.com/dotcover
        3

        Download Java Service Launcher (JSL) from http://jslwin.sourceforge.net/
        4

        Extract the JSL software to a local directory.
        5

        Copy JSL.EXE and JSL.INI anywhere on the disk, preferably to the location noted in Step 2 where the java program is located.
    Configuring and installing the Service
        6

        Configure JSL.ini with the correct parameters. The main parameters to configure are described in following steps.
        7

        Set the service name and description by setting the variables 'appname', 'servicename', 'displayname', 'servicedescription' appropriately.
        8

        Set the account and password to be used for the windows service using the variables 'account' and 'password.'
        9

        Assign the class, method and parameters that will be called when the service is stopped by setting the variables 'stopclass', 'stopmethod' and 'stopparams.'
        10

        Set up the parameters to configure the class and method to be called when the service is paused by setting 'pauseclass', 'pausemethod', 'pausesignature' and 'pauseparams.'
        11

        Set the java runtime to be used for running the program using by setting the variable ‘jrepath.’
        12

        Set the working directory which be used for running the java program by setting the variable ‘wrkdir’. This will mostly be the location noted in Section 1, Step 2.
        13

        Configure the java program to be run as a service by setting the variable ‘cmdline’. The class will be the class noted in Step1. Example: cmdline = -cp %P1%\\src com.sample.EntryClass
        14

        Alternate to Step 8 above: Use the params variable to configure the java program that will be run as a windows service.
Example :
params = 3
param00=-cp
param01=C:\\myapp\\lib\\lib.jar
param02= com.sample.EntryClass
        15

        Execute the command jsl.exe – install. This installs the service that has been configured in the previous steps.
        16

        Start the windows service just installed by using windows service manager.

Insane I Lived♥ Sane I Died♥<img src='http://i253.photobucket.com/albums/hh74/reallytired2/family%20pictures/buckeye%20stuff/clap.gif' />

Online zeal

  • Lead Admin
  • *****
Re: How to Convert a Java Program Into a Windows Service
« Reply #1 on: November 26, 2012, 09:38:40 PM »
here is well composed write up thanks for taking your time
zealous for perfection

Offline DE_Light

  • Lead Admin
  • *****
Re: How to Convert a Java Program Into a Windows Service
« Reply #2 on: May 21, 2013, 08:06:52 AM »
Gud work!


 


Inside: 3P Techies Blog

Newest Techies

Get Updates


Sign up to get latest updates delivered to your inbox. No Spam, We Promise!

Get Hosting!

a Faster web hosting service
 

Copyright © 3rd Planet Techies. All rights Reserved.

Top || Mobile ||Advertise || Contact Us || Privacy