Configure the Java agent

The standard installation for all agents uses this order of precedence.

You can configure the Java agent using:

  • Java system properties

    For example: -Dcontrast.agent.java.standalone_app_name

  • Environment variables

    For example: CONTRAST__AGENT__JAVA__STANDALONE_APP_NAME

  • Java YAML template

    For example: agent.java.standalone_app_name

Tip

Use the Contrast agent configuration editor to create or upload a YAML configuration file, validate YAML and get setting recommendations.

You may need to configure your application’s Java environment to work effectively with the agent if your system uses:

  • Standalone applications: If your JVM application server hosts a single application you should specify the name using agent.java.standalone_app_name. Certain features like route coverage and session metadata require this.

    Important

    You do not need -Dcontrast.agent.java.standalone_app_name=<example_name> if your application is deployed on any of the following servers:

    • Websphere (traditional)

    • jetty

    • Resin

    • Weblogic

    • Tomcat

    • JBoss

  • Multi-tenant application configuration: If your JVM application server hosts multiple applications during a deployment, you can distinguish applications from each other and then apply individual configuration options.

    Important

    In some cases, you may wish to configure the agent to use a single application name but do not wish to treat application server code as belonging to the application. In this case, use application.name instead. Features that require agent.java.standalone_app_name will not work with application.name.

  • TLS certificates

  • Java 9 Modules

  • Java 2 Security

  • Integrations: The Contrast Java agent, can also be configured and run in conjunction with several third-party tools, plugins and integrations. Consult the remote product documentation for information about how other products work.

Java system properties

Substitute <YourContrastJarPath> with the path to your Contrast JAR, and use these commands to learn more about system properties:

  • To generate a list of general properties using the Contrast agent JAR, use:

     java -jar <YourContrastJarPath> properties
  • Use command line with tools to search for commands. For example, these commands display a list of proxy-related properties:

    Using the built-in filter:

    java -jar <YourContrastJarPath> properties --filter=proxy

Java YAML configuration template

Use this template to configure the Java agent using a YAML configuration file. (Learn more about YAML configuration.)

Place your YAML file in the default location:

  • Unix: /etc/contrast/java/contrast_security.yaml

  • Windows: C:/ProgramData/contrast/java/contrast_security.yaml

https://docs.contrastsecurity.com/common-agent-config/java_contrast_security.yaml