Include the Java agent with a JVM argument

This document describes how to pass the -javaagent argument to the JVM for your framework. This intallation step ensures the agent is included in your app. For all app servers, ensure you pass the full path to the newrelic.jar file.

This document is simply a reference for how to pass the argument. For detailed installation procedures, see Java agent installation.

If you use Typesafe Activator with Play 2.4, add this line to your build.sbt:

javaOptions ++= Seq("-javaagent:/full/path/to/newrelic.jar")

Resin

To pass the -javaagent argument on Resin, add it to the <jvm-args> section in your resin.conf or resin.xml file:

<jvm-arg>-javaagent:/full/path/to/newrelic.jar</jvm-arg>

Solr

To pass the -javaagent argument on Solr:

Standalone Solr 5.x or higher

Add the -javaagent property to bin/solr.in.sh:

SOLR_OPTS="$SOLR_OPTS -javaagent:/full/path/to/newrelic.jar"

Standalone Solr 4.x or lower

Add the -javaagent before the start.jar:

java -javaagent:/full/path/to/newrelic.jar -jar start.jar

App server Solr

When running Solr in an application server, follow the instructions of that application server to add the -javaagent flag. Also ensure that JMX is enabled for the application server. If you don't see data in the APM UI's Solr page, follow the troubleshooting procedures for Solr data.

Spring Boot

To pass the -javaagent argument on Spring Boot, add it to command line in which you start your app. Make sure to add it before the -jar argument:

java -javaagent:/full/path/to/newrelic.jar -jar app.jar

Tanuki Wrapper

To pass the -javaagent argument on Tanuki Wrapper, add a wrapper option wrapper.conf. In the line below, substitute XXX for an unused number in this file:

wrapper.java.additional.XXX=-javaagent:/full/path/to/newrelic.jar

On Linux systems, no quotation marks are required when setting this value. This behavior may vary on other operating systems.

Tomcat

To pass the -javaagent argument on Tomcat:

With catalina.sh

Configure your catalina.sh file to use the New Relic agent using the JAVA_OPTS environment variable:

export JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar"

With catalina.bat

If you use catalina.bat to launch Tomcat, set the JAVA_OPTS variable near the top of the file:

SET JAVA_OPTS=%JAVA_OPTS% -javaagent:/full/path/to/newrelic.jar

With Windows

Select Start > Apache Tomcat X.Y.Z. > Configure Tomcat > Java.

In the Java Options text box, enter the argument. Use forward slashes / for the path separator. For Tomcat 6, add a line break after the -javaagent argument.

-javaagent:/full/path/to/newrelic.jar

Select Apply, then restart Tomcat.

With Apache Commons daemon

The version of Apache Commons Daemon (jsvc) included with Tomcat 6 does not support the -javaagent argument used by New Relic. However, a build of the jsvc daemon from the trunk source will support the -javaagent argument via the -X prefix. See the Apache bug tracking the issue.

There is a fix in the Apache Commons source repository. For more information:

Other application servers

The New Relic Java agent works on any supported app server. If your app server is not listed in this document, follow standard procedures for your app server to pass this argument to the JVM before the app jar: