This page covers installing the New Relic Java agent using Maven. Maven downloads and unpacks newrelic-java.zip as a build dependency, placing the agent files in your build directory automatically.
Compatibility and requirements
Supported
- Java 8, 11, 17, 21, 24, 25, and 26 (Java 7 supported on agent v6.5.4 and earlier only)
- Maven 3.x
maven-dependency-plugin3.1.1 or higher- Any supported app server or standalone JVM process that accepts a
-javaagentargument - See compatibility and requirements for supported framework and library version ranges
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
- A Maven project with
pom.xml
Install
Configure Maven to download newrelic-java.zip
Add the Java agent as a provided dependency in your pom.xml. Replace JAVA_AGENT_VERSION with the latest Java agent version:
<dependency> <groupId>com.newrelic.agent.java</groupId> <artifactId>newrelic-java</artifactId> <version>JAVA_AGENT_VERSION</version> <scope>provided</scope> <type>zip</type></dependency>Configure Maven to unzip the agent
Add maven-dependency-plugin to the <build><plugins> section of your pom.xml to unpack the agent zip into your build directory:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>3.1.1</version> <executions> <execution> <id>unpack-newrelic</id> <phase>package</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <includeGroupIds>com.newrelic.agent.java</includeGroupIds> <includeArtifactIds>newrelic-java</includeArtifactIds> <overWriteReleases>false</overWriteReleases> <overWriteSnapshots>false</overWriteSnapshots> <overWriteIfNewer>true</overWriteIfNewer> <outputDirectory>${project.build.directory}</outputDirectory> </configuration> </execution> </executions></plugin>After running mvn package, a newrelic/ folder appears in target/ containing:
newrelic.jar— the Java agentnewrelic.yml— the agent configuration filenewrelic-api.jar— the Java agent API jarREADME
Pass the -javaagent argument
Add the -javaagent JVM argument pointing to newrelic.jar when starting your application. The exact method depends on your app server — see Pass the JVM argument for your server for server-specific instructions.
For a Spring Boot jar, for example:
$java -javaagent:/path/to/target/newrelic/newrelic.jar -jar my-example-app.jarConfigure
Edit target/newrelic/newrelic.yml and set 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.
See Java agent configuration for all available options.
Verify your install
Restart your application. Send at least two requests, then wait 2–3 minutes and your app appears in APM & services.
If no data appears after five minutes, see No data appears (Java).