---
title: Include the Java agent with a JVM argument
source: https://docs.newrelic.com/docs/apm/agents/java-agent/additional-installation/include-java-agent-jvm-argument
---

This document describes how to pass the `-javaagent` argument to the JVM for your framework. This installation 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](https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-manual-installation).

## ColdFusion [#Installing_on_ColdFusion]

To pass the `-javaagent` argument on ColdFusion:

1.  Start your ColdFusion server and navigate to your ColdFusion admin console.
2.  From the left menu, select **SERVER SETTINGS > Java and JVM**.
3.  If using the agent API: Specify the path to `newrelic-api.jar` in the **ColdFusion Class Path** field.
4.  In the **JVM Arguments** field, add the `-javaagent` argument:

    ```
    -javaagent:/full/path/to/newrelic.jar
    ```
5.  Select **Submit Changes**, then restart your ColdFusion server.

## Geronimo [#Installing_on_Geronimo]

To pass the `-javaagent` argument on Geronimo, refer to the New Relic agent jar in the `JAVA_OPTS` environment variable when running the startup command:

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

## Glassfish [#Installing_on_Glassfish]

To pass the `-javaagent` argument on Glassfish:

1.  From the Glassfish console, select **Application Server > JVM Settings > JVM options**.
2.  On the JVM options page, select **Add JVM option**.
3.  Add an entry for the `-javaagent` argument:

    ```
    -javaagent:/full/path/to/newrelic.jar
    ```
4.  Save and restart Glassfish.

If Glassfish does not start, the `-javaagent` argument might not have been set correctly. You can change the server JVM arguments by editing the `domain.xml` file.

> #### ⚠️ IMPORTANT
>
> A bug in Glassfish 2.1 prevents classes on the bootstrap class loader (the New Relic agent) from using the Java logging API. This appears to be fixed in 2.1.1 or higher releases.

## Grails [#Installing_on_Grails]

To pass the `-javaagent` argument on Grails:

**Pass with run-app**

1.  Begin with an unzipped version of Grails.
2.  Run this command:

    ```sh
    grails -noreloading -javaagent:/full/path/to/newrelic.jar run-app
    ```

**Pass with run-war**

1.  In your Grails app, open this file with your text editor:

    ```
    grails-app/conf/BuildConfig.groovy
    ```
2.  Add or edit the JVM arguments line:

    ```ini
    grails.tomcat.jvmArgs = ["-javaagent:/full/path/to/newrelic.jar"]
    ```

## JBoss [#Installing_on_JBoss]

To pass the `-javaagent` argument on JBoss:

**Set with domain mode (6.x EAP and 7.0 AS)**

Use domain mode for JBoss versions 6.x EAP and 7.0 AS or above:

1.  Edit the JVM properties for your server group, located in:

    ```
    domain/configuration/domain.xml
    ```
2.  Modify the properties to include the `-javaagent` argument:

    ```xml
    <server-group name="main-server-group" profile="full">
      <jvm name="default">
        <jvm-options>
          <option value="-javaagent:/full/path/to/newrelic.jar"/>
        </jvm-options>
      </jvm>
      ...
    </server-group>
    ```

    > #### ⚠️ CAUTION
    >
    > A [JBoss bug in 7.0.2.Final and 7.1.0.Alpha1](https://issues.jboss.org/browse/AS7-1868) does not allow JVM options to be set in `domain.xml`. If you encounter this problem, upgrade your JBoss application server.

**Set with standalone mode (other versions)**

Use standalone mode for other platforms and versions:

| Platform                                         | Directions                                                                                                                                                                                              |
| ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Unix or macOS with 6.x EAP or 7.0.x AS and above | At the bottom of `bin/standalone.conf`, add: ````ini JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" ```  ````                                                                             |
| Windows with 6.x EAP or 7.0.x AS or higher       | In `bin/standalone.bat`, before the line: ````batch set JBOSS_ENDORSED_DIRS=%JBOSS_HOME%\lib\endorsed ```  Add:  ```batch set "JAVA_OPTS=-javaagent:C:/full/path/to/newrelic.jar %JAVA_OPTS%" ```  ```` |
| Unix or macOS with 6.x or earlier                | At the bottom of `bin/run.conf`, add this: ````ini JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" ```  ````                                                                               |
| Windows with 6.x or earlier                      | In `bin/run.bat`, before the line: ````batch set JBOSS_CLASSPATH=%RUN_CLASSPATH% ```  Add:  ```batch set "JAVA_OPTS=-javaagent:C:/full/path/to/newrelic.jar %JAVA_OPTS%" ```  ````                      |

## Jetty [#Installing_on_Jetty]

To pass the `-javaagent` argument on Jetty:

**If you set exec in `jetty.sh`**

Edit the `JAVA_OPTIONS` in your `jetty.sh` script:

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

````

**If you set exec in `start.ini`**

Add the agent path to your `start.ini` config file:

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

````

## Play [#Installing_on_Play]

To pass the `-javaagent` argument on Play:

**Play 1.2.4**

Append the `-javaagent` argument when running your Play application:

````sh
play run your_app_name -javaagent:/full/path/to/newrelic.jar
```

````

**Play 2.0**

1.  Begin with an **unzipped** distribution containing the `start` script:

    ```sh
    play clean dist && unzip dist/*.zip
    ```
2.  Append the `-javaagent` argument when starting your Play app:

    ```sh
    cd unzipped/folder; chmod a+x start; ./start -javaagent:/full/path/to/newrelic.jar
    ```

**Play 2.2**

1.  Begin with an **unzipped** distribution containing the `start` script:

    ```sh
    play clean dist && unzip target/directory/universal/*.zip
    ```
2.  Append the `-J-javaagent` argument when starting your Play app:

    ```sh
    cd unzipped/folder; ./bin/scriptname -J-javaagent:/full/path/to/newrelic.jar
    ```

    > #### 💡 TIP
    >
    > To enable page load timing, see [Manual instrumentation with Play 2.2](https://docs.newrelic.com/docs/agents/java-agent/instrumentation/page-load-timing-java#manual-play-2-2).

**Play 2.3, 2.4, and 2.5**

1.  Begin with an **unzipped** distribution containing the `start` script:

    ```sh
    activator clean dist && unzip target/directory/universal/*.zip
    ```
2.  Append the `-J-javaagent` argument when starting your Play app:

    ```sh
    cd unzipped/folder; ./bin/scriptname -J-javaagent:/full/path/to/newrelic.jar
    ```
3.  If you use Typesafe Activator with Play 2.4, add this line to your `build.sbt`:

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

## Resin [#Installing_on_Resin]

Java 8

-   Option 1: Add the `javaagent` argument via the `jvmargs` property in server's `resin.properties` file:
    ```properties
    jvm_args  : -javaagent:/full/path/to/newrelic.jar
    ```
-   Option 2: Specify the `-javaagent` argument by adding it to the `<jvm-args>` section in your `conf/resin.conf` or `conf/resin.xml` file:
    ```xml
    <jvm-arg>-javaagent:/full/path/to/newrelic.jar</jvm-arg>
    ```

Java 9 or higher

The module system introduced in Java 9 can lead to the exception `NoClassDefFoundError: java/sql/SQLException` if the `-javaagent` property is added to the `conf/resin.conf` or `conf/resin.xml` files. If you're using Java 9 or higher make sure that the `-javaagent` property is not included in those files.

Resin can be run on Java 9 or higher, with the Java agent using one of the following options:

-   Option 1: Add the `javaagent` argument via the `jvmargs` property in server's `resin.properties` file:
    ```properties
    jvm_args  : -javaagent:/full/path/to/newrelic.jar
    ```
    The Resin server can then be run with `./bin/resin.sh start`.

-   Option 2: Run resin jar with the `-javaagent` property on the command line:
    ```sh
    java -javaagent:/path/to/newrelic.jar -jar lib/resin.jar start
    ```

> #### ⚠️ IMPORTANT
>
> The agent will not work with Resin on Windows when using Java 9 or higher.

## Solr [#Installing_on_solr]

To pass the `-javaagent` argument on Solr:

**Standalone Solr 5.x or higher**

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

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

````

**Standalone Solr 4.x or lower**

Add the `-javaagent` before the `start.jar`:

````sh
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](https://docs.newrelic.com/docs/agents/java-agent/troubleshooting/solr-data-not-appearing-apm-solr-tab-java).

## Spring Boot

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

```sh
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:

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

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

## Tomcat [#Installing_on_Tomcat]

To pass the `-javaagent` argument on Tomcat:

**With setenv.sh**

Create a `CATALINA_BASE/bin/setenv.sh` script if one doesn't already exist. Configure your `setenv.sh` script to use the New Relic agent using the `CATALINA_OPTS` environment variable:

````sh
export CATALINA_OPTS="$CATALINA_OPTS -javaagent:/full/path/to/newrelic.jar"
```

````

**With setenv.bat**

Create a `CATALINA_BASE/bin/setenv.bat` script if one doesn't already exist. Configure your `setenv.bat` script to use the New Relic agent using the `CATALINA_OPTS` environment variable:

````batch
SET "CATALINA_OPTS=%CATALINA_OPTS% -javaagent:/full/path/to/newrelic.jar"
```

````

**With catalina.sh (NOT RECOMMENDED)**

> #### 💡 TIP
>
> We recommend that you do not set any variables in this script. Instead put them into a script `setenv.sh` in `CATALINA_BASE/bin` to keep your customizations separate.

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

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

````

**With catalina.bat (NOT RECOMMENDED)**

> #### 💡 TIP
>
> We recommend that you do not set any variables in this script. Instead put them into a script `setenv.bat` in `CATALINA_BASE/bin` to keep your customizations separate.

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

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

````

**With Windows**

1.  Select **Start > Apache Tomcat X.Y.Z. > Configure Tomcat > Java**.
2.  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
    ```
3.  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](https://issues.apache.org/jira/browse/DAEMON-84).

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

-   See the [Apache source repository documentation](https://commons.apache.org/svninfo.html).
-   Go directly to the [SVN source repository](https://subversion.apache.org/).

## WebLogic [#Installing_on_WebLogic]

To pass the `-javaagent` argument on WebLogic:

**Administration servers on Linux or macOS**

1.  Edit your `startWebLogic.sh` file, located in the domain's `bin` directory.
2.  Near the beginning of the file, add:

    ```sh
    export JAVA_OPTIONS="$JAVA_OPTIONS -javaagent:/full/path/to/newrelic.jar"
    ```

**Administration servers on Windows**

1.  Edit your `startWebLogic.bat` file, located in the domain's `bin` directory.
2.  Near the beginning of the file, add:

    ```batch
    set JAVA_OPTIONS=%JAVA_OPTIONS% -javaagent:"C:\full\path\to\newrelic.jar"
    ```

**Managed server instances**

For administration server instances, follow the Linux/macOS or Windows instructions. You cannot use the administration console to install administration server instances.

For managed server instances, use the admin console:

1.  From the administration console, navigate to **Environments > Servers > (select a server) > Server Start > Arguments**.
2.  From **Arguments**, add:

    ```
    -javaagent:/full/path/to/newrelic.jar
    ```
3.  Save the page, then restart your server instance.

## WebSphere [#Installing_on_Websphere]

To pass the `-javaagent` argument on WebSphere:

1.  From the admin console, select **Servers > Application servers > (select a server) > Configuration > Service Infrastructure > Java and Process Management**.
2.  Select **Process Definition > Additional Properties**, then select **Java Virtual Machine**.
3.  In the **Generic JVM arguments** field, add the `-javaagent` argument for your `newrelic.jar` file:

    ```
    -javaagent:/full/path/to/newrelic.jar
    ```
4.  Select **Apply**, then select **Save**.
5.  Restart your server.

For more information, see the documentation about [collecting WebSphere PMI metrics](https://docs.newrelic.com/docs/agents/java-agent/features/jvm-metrics-page#default-pmi).

## WebSphere Community [#Installing_on_Websphere_Community_Edition]

To pass the `-javaagent` argument on WebSphere Community Edition, refer to the New Relic agent jar in the `JAVA_OPTS` environment variable when running the startup command:

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

## WebSphere Liberty Profile [#Installing_on_WebSphere_Liberty_Profile]

To pass the `-javaagent` argument on WebSphere Liberty Profile:

1.  Edit `${server.config.dir}/jvm.options`.
2.  Add the `-javaagent` argument to point to your `newrelic.jar` file:

    ```
    -javaagent:/full/path/to/newrelic.jar
    ```
3.  Restart your server.

## Wildfly [#Installing_on_WildFly]

To pass the `-javaagent` argument on Wildfly (if using Wildfly 11 or higher, see [additional install instructions](https://docs.newrelic.com/docs/agents/java-agent/additional-installation/wildfly-version-11-installation-java)):

**Set with domain mode**

1.  Edit the JVM properties for your server group, located in:

    ```
    domain/configuration/domain.xml
    ```
2.  Modify the properties to include the `-javaagent` argument:

    ```xml
    <server-group name="main-server-group" profile="full">
      <jvm name="default">
        <jvm-options>
          <option value="-javaagent:/full/path/to/newrelic.jar"/>
        </jvm-options>
      </jvm>
      ...
    </server-group>
    ```

**Set with standalone mode**

| Platform      | Directions                                                                                                                                                                                    |
| ------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Unix or macOS | At the bottom of `bin/standalone.conf`, add: ````ini JAVA_OPTS="$JAVA_OPTS -javaagent:/full/path/to/newrelic.jar" ```  ````                                                                   |
| Windows       | In `bin/standalone.bat`, find this line: ````batch rem Setup JBoss specific properties ```  Then add:  ```batch set "JAVA_OPTS=-javaagent:C:/full/path/to/newrelic.jar %JAVA_OPTS%" ```  ```` |

## Other application servers [#other-app-servers]

The New Relic Java agent works on any [supported app server](https://docs.newrelic.com/docs/agents/java-agent/getting-started/compatibility-requirements-java-agent). 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:

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