Planning for Java CAPS Installation

Creating a Windows Service for the GlassFish Domain

After you install Java CAPS, you can create a Windows Service for the Java CAPS domain in GlassFish by running a script that uses a tool provided with GlassFish ES specifically for this purpose. The script in the instructions below requires you to create a password file.

ProcedureTo Create the Windows Service

  1. Create a text file named passwordfile and save it to a local directory. Add the following text to the file:

    AS_ADMIN_ADMINPASSWORD=adminadmin

    AS_ADMIN_MASTERPASSWORD=changeit

    AS_ADMIN_PASSWORD=adminadmin


    Note –

    If you changed any of the default passwords, substitute the actual values for the default values in the text above.


  2. Save and close the password file.

  3. Enter the following at the command line.


    Caution – Caution –

    This text, and the text in the example below, has been wrapped for readability. When you enter this command, enter it all on one line and substitute a space for each line break.



    C:\WINDOWS\system32\sc.exe create service-name 
    binPath= "fully-qualified-path-to-appservService.exe 
    \"fully-qualified-path-to-asadmin.bat 
    start-domain --user admin --passwordfile 
    fully-qualified-path-to-password-file domain-name\" 
    \"fully-qualified-path-to-asadmin.bat stop-domain domain-name\"" 
    start= auto DisplayName= "display-name"

    where:

    • service-name is the name you want to give the service; for example, “DOMAIN1”.

    • domain-name is the name of the domain you are creating the service for. The default domain is named domain1.

    • display-name is the name of the service as you want it to appear on the Services window.

    The following example creates a service named “Java CAPS DOMAIN1” that starts and stops the domain named domain1, which was installed in the default Java CAPS location. It uses the password file C:\JavaCAPS62\appserver\passwordfile. Again, in an actual command line, this would be entered all in one line with spaces in place of the line breaks below.


    C:\WINDOWS\system32\sc.exe create DOMAIN1 
    binPath= "C:\JavaCAPS62\appserver\lib\appservServer.exe 
    \"C:\JavaCAPS62\appserver\bin\asadmin.bat 
    start-domain --user admin --passwordfile C:\JavaCAPS62\appserver\passwordfile 
    domain1\" 
    \"C:\JavaCAPS62\appserver\bin\asadmin.bat stop-domain domain1\""
    start= auto DisplayName= "JavaCAPS DOMAIN1"

    The output is [SC] CreateService SUCCESS.

ProcedureTo Start, Stop, and Delete the Windows Service

In the following commands, DomainName is the name of the domain you are using for Java CAPS. By default, this is domain1.

  1. To start the Windows Service, enter the following at the command prompt:

    net start DomainName


    Note –

    The output is The SunJavaSystemAppServer DOMAIN1 service is starting.. and The SunJavaSystemAppServer DOMAIN1 service was started successfully.


  2. To stop the Windows Service, enter the following at the command prompt:

    net stop DomainName

  3. To delete the Windows Service, enter the following at the command prompt:

    sc delete DomainName