This page covers the standard installation path for the New Relic Java agent on any supported app server or JVM-based framework. Follow these steps to download the agent, configure it, and verify that data is flowing to New Relic.
Compatibility and requirements
Supported
Java 8, 11, 17, 21, 24, 25, and 26 (Java 7 supported on agent v6.5.4 and earlier only)
JVM-based languages: Java, Scala, Kotlin, and Clojure
App servers and frameworks: Tomcat, Spring Boot, JBoss/WildFly, Glassfish, Jetty, WebLogic, WebSphere, Grails, ColdFusion, Solr, Play, Resin, Tanuki Wrapper, and Geronimo — see compatibility and requirements for supported version ranges
Any JVM process that accepts a -javaagent argument
Not supported
Running alongside other APM agents — the Java agent cannot guarantee correct behavior when another APM agent is active in the same JVM
You need
A New Relic account and
A JVM with SHA-2 (256-bit) SSL support
Permission to edit your app server's startup scripts or JVM configuration
Permission to create a directory to hold the agent files
Install
Download the Java agent
Download newrelic-java.zip using one of these methods:
After unzipping, the newrelic/ directory contains the agent jar (newrelic.jar) and configuration file (newrelic.yml) that you'll configure in the next steps.
Place the agent files
Create a permanent directory and move the agent files into it:
bash
$
mkdir-p /opt/newrelic
$
mv newrelic/* /opt/newrelic/
We recommend /opt/newrelic on Linux/macOS or C:\opt\newrelic on Windows. Make sure newrelic.jar is not on your application classpath or in any directory listed in java.endorsed.dirs.
Pass the -javaagent argument
Add the -javaagent flag to your app server's JVM startup configuration, pointing to the full path of newrelic.jar. The method differs per server — expand the one that matches your environment:
Choose the method for your Tomcat setup:
Create CATALINA_BASE/bin/setenv.sh if it doesn't exist, then add:
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:/opt/newrelic/newrelic.jar
Select Apply, then restart Tomcat.
The version of Apache Commons Daemon (jsvc) bundled with Tomcat 6 does not support the -javaagent argument. A build from the trunk source supports it via the -X prefix. See the Apache bug report and Apache Commons source repository.
Add the -javaagent argument before the -jar argument on the command line:
For administration server instances, use the Linux/macOS or Windows instructions above — you cannot configure administration server instances through the admin console.
For managed server instances, use the admin console:
Navigate to Environments > Servers > (select a server) > Server Start > Arguments.
Add:
-javaagent:/opt/newrelic/newrelic.jar
Save and restart the server instance.
From the admin console, select Servers > Application servers > (select a server) > Configuration > Service Infrastructure > Java and Process Management.
Select Process Definition > Additional Properties, then select Java Virtual Machine.
When running Solr inside an application server, follow the instructions for that app server (see the other entries in this list). Also ensure JMX is enabled. If Solr data doesn't appear in APM, see troubleshooting procedures for Solr data.
bash
$
play run your_app_name -javaagent:/opt/newrelic/newrelic.jar
Start with an unzipped distribution containing the start script:
bash
$
play clean dist &&unzip dist/*.zip
Start with the -javaagent argument:
bash
$
cd unzipped/folder;chmod a+x start; ./start -javaagent:/opt/newrelic/newrelic.jar
Start with an unzipped distribution:
bash
$
play clean dist &&unzip target/directory/universal/*.zip
Use the -J-javaagent prefix:
bash
$
cd unzipped/folder; ./bin/scriptname -J-javaagent:/opt/newrelic/newrelic.jar
The Java 9 module system can cause NoClassDefFoundError: java/sql/SQLException if -javaagent is added to conf/resin.conf or conf/resin.xml. Use one of these alternatives instead:
On Linux, no quotation marks are needed around the path. This may vary on other operating systems.
Pass the agent jar in JAVA_OPTS when running the Geronimo startup command:
bash
$
exportJAVA_OPTS="$JAVA_OPTS -javaagent:/opt/newrelic/newrelic.jar"&& geronimo run
Configure
Edit newrelic/newrelic.yml and set these two required values:
license_key:'YOUR_LICENSE_KEY'
app_name:'My Application'
The agent reads newrelic.yml from the same directory as newrelic.jar at startup. You can also override any setting using Java system properties (e.g. -Dnewrelic.config.license_key=YOUR_KEY) or environment variables.
When using the config file, restrict permissions to read/write for the owner of the application server process only: