Java Agent Installation


Getting Started

Two files are required to start the New Relic java agent - newrelic.jar and newrelic.yml. newrelic.jar contains the agent class files, and the newrelic.yml file contains configuration information for the New Relic agent, including your license key, application name, ssl settings, etc. For your convenience, you can download a single zip file containing both the jar and yml files.

If you don't already have a New Relic RPM account you can create one using this link: http://www.newrelic.com/get-RPM.html. Once you have an account, you can download your newrelic.yml file by logging into http://rpm.newrelic.com and clicking the "Support" link in in the upper right. Click on the "Download the latest Java agent" link to download the files you'll need.

The agent requires Java 1.5 or later.


Installation

The NewRelic Java agent bootstraps using the -javaagent command line option.

Create a directory in your application server home directory named newrelic and copy/unzip the newrelic.jar and newrelic.yml files into it. On server startup the agent will search for the newrelic.yml file in the directory containing the newrelic.jar file. The agent log will be written relative to the agent jar file in a directory named 'logs'. Start or re-start your app server with the -javaagent parameters and log in to NewRelic RPM to see your app's performance information. It takes about 2 minutes for the application data to show up in RPM. By default, your data will appear under an application named "My Application". You can change this by updating the app_name setting in newrelic.yml.


Installing on Tomcat

The Tomcat startup script (catalina.sh) can be configured to use the New Relic agent using the JAVA_OPTS environment variable:

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

The javaagent switch should reference the full path to the newrelic jar file.

If you're installing on a Windows operating system, read this article.

If using the Apache Commons Daemon (jsvc) to start Tomcat,
read this article.


Installing on Jetty

The Jetty startup script (jetty.sh) can be configured using the JAVA_OPTIONS environment variable:

export JAVA_OPTIONS="${JAVA_OPTIONS} -javaagent:/full/path/to/newrelic.jar"

The javaagent switch should reference the full path to the newrelic jar file.


Installing on JBoss

If you're installing on Unix or Mac OS, add this line to the bottom of bin/run.conf:

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

The javaagent switch should reference the full path to the newrelic jar file.

If you're installing on Windows, add this line to bin/run.bat:

set "JAVA_OPTS=-javaagent:%JAVA_OPTS%"

Put it before the line:
set JBOSS_CLASSPATH=%RUN_CLASSPATH%

The javaagent switch should reference the full path to the newrelic jar file. Use forward slashes. For example:

C:/newrelic/newrelic.jar


Installing on Glassfish

See installing on Glassfish.


Installing on Apache Geronimo

For Apache Geronimo, refer to the RPM agent jar in the JAVA_OPTS environment variable when running the startup command:

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


Installing on WebSphere

See installing on WebSphere.

For WebSphere Community Edition, refer to the RPM agent jar in the JAVA_OPTS environment variable when running the startup command:

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


Installing on Other Application Servers

The New Relic Java agent should work on any application server by passing the -javaagent switch to the JVM.