Snyk Documentation

Installing the Snyk runtime agent for Java

Install the Snyk runtime agent for Java:

  1. Download the runtime agent from this link and unzip the archive.
  2. From the extracted files, copy snyk-java-runtime-agent.jar alongside your application files.
  3. Create a file at the same location as the agent jar file. The properties file should contain the Snyk project ID. For example:
  4. Add the agent as a command-line argument to the Java command that you use to start your application. For example:
    java -javaagent:path/to/snyk-java-runtime-agent.jar -jar my-app.jar
  5. If you are using Apache Maven, add the following jar file to your Maven options environment variable as follows:
  6. If you are using JavaEE containers such as GlassFish, add the following jar file to the JVM Options:
  7. Once you have successfully added the agent, logging begins to appear in the stderr (standard error) file shortly after the JVM (Java virtual machine) starts up, as in the following example:
snyk-agent initialisation: startup
snyk-agent initialisation: trying: /opt/app-1/agent/
snyk-agent initialisation: switching logging to: /opt/app-1/agent/snyk-logs/agent-log-2001-02-03T04:05:06.log

Example of Java code when Snyk runtime agent is added successfully

Related topics