# WLOC Administration Console Online Help

# Defining variables for multiple Java processes

To simplify the task of creating multiple copies of Java processes in a service, WLOC provides the capability to define the common characteristics of the process in a template, and to use variables to replace common parameters. You can then use the template to generate multiple copies of the process without having to physically configure duplicates in the metadata configuration. When you create the template, you define the following:

- The common parameters that apply to all instances of the process, including specifying the number of copies of the process that you want to create using the Max Copies parameter. See Define process groups for a service.
- A set of variables that will be used to replace references in the template.

Note: The number of values that you specify in the variables must be equal to the number of copies to be created.

To take advantage of the variable definitions, you can insert variable references into certain attributes of the `jvm-instance` definition. You can specify variables for the following attributes:

- Java arguments `<JavaArgs>`
- JVM arguments `<JvmArgs>`
- Instance directory `<InstanceDir>`
- Host `<Host>`
- Port `<Port>`
- JMX Service URL `<JmxServiceUrl>`

To define variables for a JVM process:

1. Access the Variables page in any of the following ways:
   - When creating a service process from scratch, select a newly created process group in the Process Group table, and then click the Variables button on the ensuing Process Properties page (for editing processes specified for the service). See Define process groups for a service.
   - When adding more JVMs to a process group using a Service's Configured Process Groups table, click the Variables button on the Process Properties page. See Modify services, process groups, and instances.
   - When using the Inventory pane to manage a service, drill down to a configured JVM instance using either the Inventory tree or the Configured Process Groups table, and then click the Variables tab. See Grouping inventory components.

   The JVM variables that are currently defined are displayed.

2. On the Variables page, click New.

   To modify an existing JVM variable, click on its name in the Variable table.

3. On the Variable Properties page, set the JVM variable properties, as follows.

   Field | Description
   --- | ---
   Name | Enter a name for the JVM variable.
   Value | Enter the value of the JVM variable. There are two kinds of variables: Scalar values that replace another value. For example, entering `9001` creates a variable of `${port}=9001`, which could be used to represent that all instances use the same port. Array values that provide a set of values for another value. You can specify array variables as follows: As a single value to specify that all instances use the same value. For example, `${port}=9001`. In a comma-separated list. For example, entering `9001,9002,9003` creates a variable of `${ManagedPort}=9001,9002,9003`, which means that three instances of the JVM should use ports 9001-9003. As a range of values. For example, `${ManagedPort}=@range{9010,9013}`.

4. Click Save.

   The variable is saved and the following confirmation is displayed:

       New JVM Variable created

5. Repeats steps 2-4 to create additional variables for the process group.
6. If necessary, you may need to update the template definition after the variables are created. For more information, see the WLOC Configuration Guide.

After you finish

To delete variables, select the variable that you want to delete from the Variable Properties table and click Delete.