NexJ Logo

Creating a new environment file

An environment file must be created before you can begin to configure your model.

To create a new environment file in NexJ Studio:

  1. In the Deployment layer, click the Environments tab.
  2. Right-click the list field in the Environments tab and select New Environment.
    The New Environment dialog opens.
  3. Give your environment a name and click Finish.
    The New Environment dialog closes.

An environment with the name you specified is now listed in the Environments tab. The environment file can also be found in the env folder of the project. You can now add environment arguments to the environment, either using the NexJ Studio environment editor or directly in the source by opening the environment file in a text editor. For a list of environment arguments and an example of environment file source, see Example environment settings for NexJ CRM deployment.

In new environment files, the httpGZip property is not initially set. It is recommended that you set it to true. This improves performance by activating Gzip compression for HTTP traffic and helps minimize network bandwidth use.

This setting is surfaced in NexJ Studio as the Compressed HTTP Response in the Communication tab.

Specifying environment properties through a properties file

You can use a properties file to set your environment properties through variables. This removes the need to edit the environment file directly every time you modify a setting and is useful if you want to experiment with the property values For example, to use a different HTTP URL for unit testing and staging from that you use in production, you can create three separate properties files named  development.propertiesunittest.properties, and staging.properties, specify a different value for the httpURL property in each of the properties files, and set them all for use with the same environment file. 

The argument is specified in the environment file as a variable that refers to the properties file which is being used in the deployment. The property value is specified in the properties file and may be different for each properties file.

In case of a conflict, properties specified through the jvm.conf and modeld.conf files override the top-level variables in the environment file. For more information about jvm.conf and modeld.conf, see Specifying JVM arguments and system properties.

To use a property file for a Model Server deployment:

  1. Create one or more properties files as needed.

    You can create a properties file by one of the following methods:

    • In the env directory of your project folder, create a text file and change its extension to .properties
    • In NexJ Studio, open the environment in the Deployment layer. In the top right corner of the environment editor, click the dropdown next to the Open Properties button and select Add.
  2. In the properties file, specify property values in the following format:
    <propertyName>=<propertyValue>
    For example, callRecordsEnabled=true or cloneCount=1.
  3. In the environment file, specify the property that needs to be pulled from the properties file in the following format:
    <environmentAttributeName>="${<propertyName>}"
    where  environmentAttributeName  is the attribute name as mentioned in the environment file, and  propertyName  is the name of the property in the properties file. The propertyValue associated with the property will replace propertyName. For example, callRecordSetting="${callRecordsEnabled}". When you deploy,  callRecordsEnabled  is replaced by true based on the setting in the properties file.
  4. In the properties file, specify the environment file in the following format:
    config=<environmentFileName>.environment

    For example, config=development.environment.
  5. Save the files.

The properties files and environment file have been created and can be used in a deployment.

When you are ready to deploy, select the properties file you want to use for the deployment:

  • If using NexJ Studio, select the file from the Set current server dropdown.
  • If using the command line, specify the property file using the following command:
    -Dserver.properties=$<PROP_FILE> \

    where PROP_FILE is the name of the properties file you want to use for the environment, for example, staging.properties.

The server gets deployed with the mapped values from the selected properties file.