---
title: AWS Elastic Beanstalk installation for Java
source: https://docs.newrelic.com/docs/apm/agents/java-agent/additional-installation/aws-elastic-beanstalk-installation-java
---

If you are an [AWS Elastic Beanstalk](http://docs.amazonwebservices.com/elasticbeanstalk/latest/gsg/) user, the Java agent requires additional configuration.

## Prerequisites

Before completing the configuration, you must first:

-   Create a supported [Amazon Web Services account](http://aws.amazon.com/elasticbeanstalk/).
-   Create a [New Relic account](http://newrelic.com/signup).
-   [Download and install the Java agent](https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-manual-installation).

To complete Java agent installation on AWS Elastic Beanstalk, follow the steps for your platform:

## Tomcat platform

For applications deployed with the AWS Elastic Beanstalk Tomcat Platform:

1.  In your WAR file, add the `newrelic.jar` and `newrelic.yml` files to `WEB-INF/lib/`.

2.  Repackage and deploy your new WAR file as a new application or an update to a previous application.

3.  Locate and connect to the underlaying EC2 instance. Once connected, find the path to `newrelic.jar` file using this command - ensure you search one directory at a time. Use either `/var` or `/usr` as appropriate.

    ```sh
    sudo find /var -name "newrelic.jar"
    sudo find /usr -name "newrelic.jar"
    ```

    To pass the `-javaagent` flag to the JVM:

4.  In the AWS console, open the Elastic Beanstalk.

5.  Select the relevant region.

6.  Select your environment.

7.  In the left pane, select **Configurations**.

8.  Scroll to **Updates, monitoring, and logging** and select **Edit** in the upper right corner.

9.  Scroll to **Platform Software** and add the following line to the **JVM Options** field:

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

10. Select **Apply** to save.

Your Elastic Beanstalk will then update your environment.

## Java SE Platform

For applications deployed with the AWS Elastic Beanstalk Java SE Platform:

1.  Add the `newrelic.jar` and `newrelic.yml` files to your project, such in a subdirectory named `opt/newrelic`.

2.  To use custom JVM arguments with your Java SE application, we recommend that you include a `Procfile` at the root of the source bundle of your application. See [Java SE documentation](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html) for details.

    Pass the `-javaagent` flag as a JVM argument in the `Procfile`:

    ```makefile
    web:java -javaagent:path/from/bundle/root/to/newrelic.jar -jar <your-application>.jar
    ```

3.  Repackage and deploy the source bundle to your Elastic Beanstalk.
