Skip Navigation
Show nav
Heroku Dev Center Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
Heroku Dev Center Dev Center
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
    • .NET
  • Documentation
  • Changelog
  • More
    Additional Resources
    • Home
    • Elements
    • Products
    • Pricing
    • Careers
    • Help
    • Status
    • Events
    • Podcasts
    • Compliance Center
    Heroku Blog

    Heroku Blog

    Find out what's new with Heroku on our blog.

    Visit Blog
  • Log in or Sign up
View categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Buildpacks
    • Platform Principles
  • Developer Tools
    • AI Tools
    • Command Line
    • Heroku VS Code Extension
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery & Integration (Heroku Flow)
    • Continuous Integration
  • Language Support
    • Node.js
      • Node.js Behavior in Heroku
      • Working with Node.js
      • Troubleshooting Node.js Apps
    • Ruby
      • Rails Support
        • Working with Rails
      • Working with Bundler
      • Working with Ruby
      • Ruby Behavior in Heroku
      • Troubleshooting Ruby Apps
    • Python
      • Working with Python
      • Background Jobs in Python
      • Python Behavior in Heroku
      • Working with Django
    • Java
      • Java Behavior in Heroku
      • Working with Java
      • Working with Maven
      • Working with Spring Boot
      • Troubleshooting Java Apps
    • PHP
      • Working with PHP
      • PHP Behavior in Heroku
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
    • .NET
      • Working with .NET
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
      • Migrating to Heroku Postgres
    • Heroku Key-Value Store
    • Apache Kafka on Heroku
    • Other Data Stores
  • AI
    • Inference Essentials
    • Inference API
    • Inference Quick Start Guides
    • AI Models
    • Tool Use
    • AI Integrations
    • Vector Database
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
      • Single Sign-on (SSO)
    • Private Spaces
      • Infrastructure Networking
    • Compliance
  • Heroku Enterprise
    • Enterprise Accounts
    • Enterprise Teams
  • Patterns & Best Practices
  • Extending Heroku
    • Platform API
    • App Webhooks
    • Heroku Labs
    • Building Add-ons
      • Add-on Development Tasks
      • Add-on APIs
      • Add-on Guidelines & Requirements
    • Building CLI Plugins
    • Developing Buildpacks
    • Dev Center
  • Accounts & Billing
  • Troubleshooting & Support
  • Integrating with Salesforce
    • Heroku AppLink
      • Getting Started with Heroku AppLink
      • Working with Heroku AppLink
      • Heroku AppLink Reference
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Other Salesforce Integrations
  • Language Support
  • Scala
  • Heroku Scala Support

Heroku Scala Support

English — 日本語に切り替える

Table of Contents [expand]

  • Activation
  • Environment Variables
  • Supported sbt versions
  • Build Behavior
  • Runtime Behavior
  • Postgres Auto-Provisioning

Last updated November 21, 2025

This document describes the general behavior of Heroku as it relates to the recognition and execution of Scala applications. For a more detailed explanation of how to deploy an application, see Getting Started with Scala on Heroku.

Activation

Heroku recognizes Scala applications when sbt project files are found (such as *.sbt or project/build.properties).

When a deployed application is recognized as a Scala application, Heroku responds with -----> Scala app detected.

$ git push heroku main
-----> Scala app detected

You can deploy Scala applications that use Maven as well, but they’re treated as Java applications, so Heroku Java Support applies.

Environment Variables

The following environment variables are set in the dyno at boot-time:

  • PORT: the web process binds to this HTTP port
  • JAVA_HOME: the location of the JDK install directory
  • LD_LIBRARY_PATH: the location of the JDK shared libraries
  • JDBC_DATABASE_URL: If a DATABASE_URL variable is present, this variable is populated with the converted form. See Connecting to Relational Databases on Heroku with Java for more information.
  • JAVA_TOOL_OPTIONS: default Java options based on dyno size

Resizing dynos automatically changes Java memory settings. You can manually adjust the JAVA_OPTS config var to override these defaults.

When a Java process is started on your dyno, the following Java options are automatically picked up:

  • -Dfile.encoding=UTF-8

These options are configured as part of the environment variable JAVA_TOOL_OPTIONS. It’s intended to augment a command line in environments where the command line can’t be accessed or modified. If you must override these settings, you can either define your preferred options in the Procfile command, which takes precedence, or you can set your own JAVA_TOOL_OPTIONS config var.

Adjusting Environment for a Dyno Size

When you select a new dyno type some JVM flags are automatically added to JAVA_TOOL_OPTIONS.

Cedar

Cedar-generation dynos have JAVA_TOOL_OPTIONS set to the following per dyno size:

Plan JAVA_TOOL_OPTIONS
Eco -Xmx300m -Xss512k -XX:CICompilerCount=2
Basic -Xmx300m -Xss512k -XX:CICompilerCount=2
Standard-1X -Xmx300m -Xss512k -XX:CICompilerCount=2
Standard-2X -Xmx671m -XX:CICompilerCount=2
Private/Shield-S -Xmx671m -XX:CICompilerCount=2
Performance/Private/Shield-M -Xmx2g
Performance/Private/Shield-L -Xmx12g
Performance/Private/Shield-L-RAM -XX:MaxRAMPercentage=80.0
Performance/Private/Shield-XL -XX:MaxRAMPercentage=80.0
Performance/Private/Shield-2XL -XX:MaxRAMPercentage=80.0

Fir

All Fir-generation dynos have JAVA_TOOL_OPTIONS set to -XX:MaxRAMPercentage=80.0.

Supported sbt versions

Applications must include a /project/build.properties file with the sbt.version property.

sbt version Support status
0.x Unsupported (end-of-life)
1.x Supported
2.x Not yet supported

sbt release candidates, betas, and other pre-release versions of supported major versions are allowed.

Build Behavior

The Heroku Scala buildpack runs sbt compile stage to build the application. Applications must include a stage task, which performs any tasks needed to prepare an application to be run in-place.

sbt-native-packager

The recommended approach is to use sbt-native-packager, which adds a stage task to sbt that packages the application with all dependencies and generates start scripts. To use the plugin, create a /project/plugins.sbt file containing:

addSbtPlugin("com.github.sbt" % "sbt-native-packager" % "1.11.4")

Then enable the plugin in your build.sbt:

enablePlugins(JavaAppPackaging)

For more information, see the sbt-native-packager documentation.

Play Framework applications

Play Framework applications automatically include sbt-native-packager and don’t require any additional configuration. The Play plugin enables the necessary packaging and staging tasks out of the box.

Custom stage task

Or you can write a custom stage task by putting something like this in your build.sbt:

val stage = taskKey[Unit]("Stage task")

stage := {
  // Make stage depend on compile
  // You can depend on other tasks or add custom logic here
  (Compile / compile).value
}

You can test your task by running sbt compile stage locally.

Clean Builds

In some cases, builds must clean artifacts before compiling. If a clean build is necessary, configure builds to perform clean by setting SBT_CLEAN=true:

$ heroku config:set SBT_CLEAN=true
Setting config vars and restarting example-app... done, v17
SBT_CLEAN: true

All subsequent deploys use the clean task. To remove the clean task, unset SBT_CLEAN:

$ heroku config:unset SBT_CLEAN
Unsetting SBT_CLEAN and restarting example-app... done, v18

Runtime Behavior

If you follow the recommendation to use sbt-native-packager to package your Scala application, the buildpack automatically creates the required process types to start your application. The buildpack detects the generated start script and creates a default web process type:

web: target/universal/stage/bin/appname

Play Framework applications also use sbt-native-packager, so they receive the same automatic process type configuration.

If you’re not using sbt-native-packager, you must provide a custom Procfile in the root of your project to specify how to start your application.

Supported JDK Versions

Refer to the Java support article.

Specifying a Java Version

Refer to the Java support article.

Postgres Auto-Provisioning

This section is only applicable to accounts created before May 15, 2023 or if you asked Heroku Support to enable auto-provisioning for your account.

A Heroku Postgres database automatically provisions on the first deploy of your Scala applications. This auto-provisioning populates the DATABASE_URL environment variable.

If you don’t want the Postgres add-on, remove it by running:

$ heroku addons:destroy DATABASE --app example-app

Feedback

Log in to submit feedback.

Information & Support

  • Getting Started
  • Documentation
  • Changelog
  • Compliance Center
  • Training & Education
  • Blog
  • Support Channels
  • Status

Language Reference

  • Node.js
  • Ruby
  • Java
  • PHP
  • Python
  • Go
  • Scala
  • Clojure
  • .NET

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing
  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Github
  • LinkedIn
  • © 2025 Salesforce, Inc. All rights reserved. Various trademarks held by their respective owners. Salesforce Tower, 415 Mission Street, 3rd Floor, San Francisco, CA 94105, United States
  • heroku.com
  • Legal
  • Terms of Service
  • Privacy Information
  • Responsible Disclosure
  • Trust
  • Contact
  • Cookie Preferences
  • Your Privacy Choices