Configure the Java agent for Tomcat

First, download the Java agent JAR from one of these repositories:

Use the guidelines below to configure the Java agent depending on how you run Contrast with Tomcat.

Run from setenv.bat

If you have a setenv.bat or file as recommended by Tomcat, add the -javaagent configuration in that file in CATALINA_OPTS.

Run from Windows on Unix

  1. Create a new startup script. Replace <YourContrastJarPath> with the path to your Contrast JAR file and substitute your Tomcat server for your environment.

    • Windows: Use startup-with-contrast.bat, for example:

      set "CATALINA_OPTS=%CATALINA_OPTS% -javaagent:<YourContrastJarPath>"
      call <TomcatDirectory>\bin\startup.bat

      Unix: Use, for example:

      export CATALINA_OPTS="$CATALINA_OPTS -javaagent:<YourContrastJarPath>"
  2. This should enable the Contrast JVM parameters and call the startup script. This new script will start up your server with Contrast.

Run on the Tomcat service in Windows

  1. If you run Tomcat as a service, open the Tomcat service manager and change the JVM options to add the agent.

  2. Double-click the Tomcat icon in the system tray (or right-click and select Configure). (If the icon isn't there, you might have to start it manually by running tomcat9w.exe in the Tomcat bin directory.)

  3. Switch to the Java tab to see where you need to add the -javaagent flag.

Run Tomcat with Java 2 security

  1. Create a contrast.policy file that contains this code (or append it to the catalina.policy file). Replace <YourContrastJarPath> with the path to your Contrast JAR file. For example:

    grant codeBase "file:<YourContrastJarPath>" {
  2. Append the contrast.policy file to the $CATALINA_HOME/conf/catalina.policy file. No additional configuration is needed. Run your Tomcat installation with command-line parameter -security.