---
title: Java agent with Scala on Heroku
source: https://docs.newrelic.com/docs/apm/agents/java-agent/heroku/java-agent-scala-heroku
---

[Heroku](https://devcenter.heroku.com/articles/newrelic) is a Platform as a Service (PaaS) solution for hosting web applications in various agent languages, including Scala. With New Relic, you can extend Heroku with metrics from [APM](https://docs.newrelic.com/docs/apm/new-relic-apm) and [browser monitoring](https://docs.newrelic.com/docs/browser/new-relic-browser).

> #### 💡 TIP
>
> For non-Scala installations, see [Java agent and Heroku](https://docs.newrelic.com/docs/agents/java-agent/heroku/java-agent-heroku).

## Compatibility and requirements [#requirements]

-   Java 7 or higher
-   Latest New Relic [Java agent version](https://docs.newrelic.com/docs/release-notes/agent-release-notes/java-release-notes)

## 1. Enable the New Relic add-on [#enable-add-on]

After you ensure that you [meet the requirements](#requirements), enable the New Relic agent add-on in Heroku.

> #### ⚠️ CAUTION
>
> You must [deploy your Java app to Heroku](https://devcenter.heroku.com/articles/getting-started-with-java#introduction), following the Heroku instructions at least through the [Deploy the app](https://devcenter.heroku.com/articles/getting-started-with-java#deploy-the-app) step, before you can enable the New Relic agent add-on.

1.  Log in to your Heroku account.
2.  From the [APM Add-On Page](https://elements.heroku.com/addons/newrelic#pricing), select a subscription plan.
3.  Select **Install APM**, and then select your target app from the dropdown.

Installing the add-on automatically creates a New Relic account and configures access for Heroku servers.

## 2. Configure your Heroku environment for New Relic [#configure-heroku-environment]

After you complete the [requirements](#requirements) and [enable the New Relic add-on](#enable-add-on), configure your Scala Heroku environment for New Relic:

1.  Edit your `Procfile` to point to the agent jar in your app's root folder. Replace the contents of the file, substituting `X.Y.Z` with the [latest agent version](https://docs.newrelic.com/docs/agents/java-agent/getting-started/java-release-notes):

    ```procfile
    web: target/universal/stage/bin/play-getting-started -Dhttp.port=${PORT} -J-javaagent:/app/target/universal/stage/lib/com.newrelic.agent.java.newrelic-agent-X.Y.Z.jar -J-Dnewrelic.config.file=conf/newrelic.yml
    ```

    OR

    Identify the path to `newrelic.jar` with the `JAVA_OPTS` [environment variable](https://devcenter.heroku.com/articles/config-vars).
2.  Edit your `build.sbt`. Call the agent, substituting `X.Y.Z` with the [latest Java agent version](https://docs.newrelic.com/docs/agents/java-agent/getting-started/java-release-notes):

    **Custom build.sbt**

    ````scala
    name := """play-getting-started"""
    version := "1.0-SNAPSHOT"
    lazy val root = (project in file(".")).enablePlugins(PlayScala)
    scalaVersion := "2.11.7"
    libraryDependencies ++= Seq(
        jdbc,
        cache,
        "org.postgresql" % "postgresql" % "9.4-1201-jdbc41",
        ws
    )
    libraryDependencies <+= scalaVersion("org.scala-lang" % "scala-compiler" % _ )
    libraryDependencies ++= Seq("com.newrelic.agent.java" % "newrelic-agent" % "X.Y.Z")
    libraryDependencies ++= Seq("com.newrelic.agent.java" % "newrelic-api" % "X.Y.Z")
    ```

    ````
3.  Download a customized `newrelic.yml` file from your APM account settings:

    **How to download a custom `newrelic.yml`**

    1.  Log in to [dashboard.heroku.com](https://dashboard.heroku.com).
    2.  Select your app.
    3.  Select **Add-ons > APM**.
    4.  [Get the New Relic Java agent.](https://docs.newrelic.com/docs/agents/java-agent/installation/install-java-agent/#download-agent)
    5.  Unzip the downloaded file.
    6.  Copy `newrelic.yml` to the `scala-getting-started/conf` directory:
4.  Edit `newrelic.yml` to customize the [`app_name`](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#cfg-app_name) setting with a [descriptive app name](https://docs.newrelic.com/docs/agents/manage-apm-agents/app-naming/name-your-application).
5.  Also in `newrelic.yml`, add your [license key](https://docs.newrelic.com/docs/apis/intro-apis/new-relic-api-keys/#ingest-license-key) to the [`license_key`](https://docs.newrelic.com/docs/agents/java-agent/configuration/java-agent-configuration-config-file#cfg-license_key) setting.

## 3. Push your changes and open the app [#push-changes]

After you [configure your Heroku environment for New Relic](#configure-heroku-environment), push your changes and open the app to monitor it with New Relic.

1.  Push your changes to the dyno with this Heroku toolbelt command:

    ```bash
    git add .
    git commit -m 'YOUR COMMIT MESSAGE'
    git push heroku master
    ```
2.  Open your app in your browser with this Heroku toolbelt command:

    ```bash
    heroku open
    ```
3.  Generate some traffic to your app and wait a few minutes.
4.  Check your app's performance in Heroku by selecting your app and then selecting the New Relic add-on.

If no data appears or if you have problems, follow the [troubleshooting](#troubleshooting) tips.

## Troubleshooting your installation [#troubleshooting]

-   If you don't see the New Relic add-on after you generate traffic, go to Heroku, select **Find more add ons**, and add the APM add-on.
-   If no data appears after waiting a few minutes, see [No data appears with Heroku (Java)](https://docs.newrelic.com/docs/agents/java-agent/heroku/no-data-appears-heroku-java).
