Deep-dive on the Next Gen Platform. Join the Webinar!

Skip Navigation
Show nav
Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • 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

    Visit the Heroku Blog

    Find news and updates from Heroku in the blog.

    Visit Blog
  • Log inorSign up
Hide categories

Categories

  • Heroku Architecture
    • Compute (Dynos)
      • Dyno Management
      • Dyno Concepts
      • Dyno Behavior
      • Dyno Reference
      • Dyno Troubleshooting
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Developer 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
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • Ruby
      • Rails Support
      • 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
      • PHP Behavior in Heroku
      • Working with PHP
    • 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
    • Working with AI
  • 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
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
  • 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
  • Language Support
  • Java
  • Java Behavior in Heroku
  • Java Buildpack Behavior

Java Buildpack Behavior

Last updated April 22, 2025

Table of Contents

  • Activation
  • Build Behavior
  • Environment Variables
  • Adjusting Environment for a Dyno Size
  • Postgres Auto-Provisioning

The Heroku Platform and Java buildpack has the following behavior for any type of Java application deployed.

Activation

The default build system for Java applications on Heroku is Maven. Heroku Java support for Maven is applied to applications that contain a pom.xml file.

Build Behavior

Run the command to build your app:

$ mvn -B -DskipTests clean dependency:list install

If Heroku detects an mvnw script in your application’s repository, it runs this script instead of the default Maven installation. You can override this behavior by explicitly setting a Maven version.

The Maven repo is cached between builds to improve performance.

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
  • JAVA_OPTS: default Java options based on dyno size (identical to JAVA_TOOL_OPTIONS)

JAVA_TOOL_OPTIONS

Java supports JAVA_TOOL_OPTIONS and it’s intended to augment a command line in environments where the command line can’t be accessed or modified. Heroku uses this value to set default Java options based on dyno size. Since Java automatically picks it up, you don’t need to include it in your Procfile command.

You can override these settings in the Procfile command, which takes precedence over the defaults. For example, to change the default of -Xmx300m, you can pass in:

web: java -Xms150M -jar target/myapp.jar

You can also set your own JAVA_TOOL_OPTIONS config var. Setting your own appends the value to Heroku’s defaults and takes precedence. Individual options not overridden in the Procfile command or custom JAVA_TOOL_OPTIONS are still in effect.

When a Java process is started on your dyno, the following Java options are added to JAVA_TOOL_OPTIONS and automatically picked up by Java:

  • -Dfile.encoding=UTF-8

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 -XX:MaxRAMPercentage=80.0
Performance/Private/Shield-L -XX:MaxRAMPercentage=80.0
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.

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.

 

This section is not applicable to Fir-generation apps.

A Heroku Postgres database automatically provisions on the first deploy of your Java applications. These apps must have a dependency on the Postgres JDBC driver or pgjdbc-ng driver in their pom.xml. 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

Keep reading

  • Java Behavior in Heroku

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