This document explains how to install the Java agent using Gradle. For information on manually installing the Java agent, see Install the Java agent and Java agent configuration: Config file .
Install agent package using Gradle Install the New Relic Java agent, using either of these options:
Install complete agent package This section explains how to configure Gradle to download and unzip the newrelic-java.zip
file, which contains all New Relic Java agent components:
newrelic.yml
(agent configuration file)
newrelic.jar
(Java agent jar)
newrelic-api.jar
(Java agent API jar)
README
To do this:
Configure your build.gradle
file with the plugin you will use to download the agent. For example:
id "de.undercouch.download" version "3.4.3"
Add tasks to download and unzip the agent. For example:
task downloadNewrelic(type: Download) {
src 'https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip'
task unzipNewrelic(type: Copy) {
from zipTree(file('newrelic/newrelic-java.zip'))
Run the tasks to download and unzip the agent. For example:
./gradlew downloadNewrelic
This will download the newrelic-java.zip
file into a newrelic/
directory and then unzip it in the same directory.
Here is an example build.gradle
file for working with the zip file: id "de.undercouch.download" version "3.4.3"
sourceCompatibility = 1.8
task downloadNewrelic(type: Download) {
src 'https://download.newrelic.com/newrelic/java-agent/newrelic-agent/current/newrelic-java.zip'
task unzipNewrelic(type: Copy) {
from zipTree(file('newrelic/newrelic-java.zip'))
Install individual components This section explains how to configure Gradle to download individual components of the Java agent, specifically the newrelic.jar
and the newrelic-api.jar
.
Configure your build.gradle
file to download either newrelic.jar
or newrelic-api.jar
. Here's an example for downloading newrelic.jar
:
dependencies {
compile group: 'com.newrelic.agent.java', name: 'newrelic-agent', version: 'JAVA_AGENT_VERSION '
}
Here's an example for downloading newrelic-api.jar
:
dependencies {
compile group: 'com.newrelic.agent.java', name: 'newrelic-api', version: 'JAVA_AGENT_VERSION '
}
Replace JAVA_AGENT_VERSION with the latest Java agent version .
Locate the newrelic.yml
file you received when creating your New Relic account or download one for the version of the agent that you are using.
Here is an example build.gradle
for working with the individual components (Java agent and API jars). sourceCompatibility = 1.8
compile group: 'com.newrelic.agent.java', name: 'newrelic-agent', version: '4.11.0'
compile group: 'com.newrelic.agent.java', name: 'newrelic-api', version: '4.11.0'
Place newrelic.yml
in the same folder as newrelic.jar
, unless you specify otherwise in the JVM arg Dnewrelic.config.file
.
Configure the newrelic.yml
file (or JVM system properties ) with your license_key
and app_name
.
Pass -javaagent:/path/to/newrelic.jar
to the JVM running your application server.
Optional: If using the New Relic Java agent API , make the API jar available at compile time by adding it to your application class path.
Generate some traffic for your app, then wait a few minutes for data to appear in the APM Summary page . If nothing appears, follow the troubleshooting procedures .
For more helpIf you need more help, check out these support and learning resources: