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
    • Platform Principles
    • Buildpacks
  • 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
      • Working with Node.js
      • Troubleshooting Node.js Apps
      • Node.js Behavior in Heroku
    • 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
  • Java
  • Java Behavior in Heroku
  • Java Buildpack Behavior

Java Buildpack Behavior

English — 日本語に切り替える

Table of Contents [expand]

  • Activation
  • Build Behavior
  • Environment Variables
  • Adjusting Environment for a Dyno Size

Last updated February 26, 2026

The Java buildpack builds and deploys Maven-based Java applications on Heroku.

Activation

The Java buildpack applies to applications that contain a pom.xml file.

Build Behavior

We recommend using the Maven Wrapper to lock your project to a specific Maven version. If your repository contains an mvnw script and a .mvn/wrapper/maven-wrapper.properties file, the buildpack uses it automatically. If no wrapper is present, the buildpack falls back to its own Maven installation. You can specify which Maven version to use in that case.

The buildpack runs the following default build command:

./mvnw -B -DskipTests clean dependency:list install

The Maven repository is cached between builds to improve performance.

Environment Variables

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

  • PORT: the HTTP port your web process binds to
  • JAVA_HOME: the JDK install directory
  • LD_LIBRARY_PATH: the JDK shared libraries directory
  • JDBC_DATABASE_URL: if a DATABASE_URL variable is present, this variable contains the converted JDBC form. See Connecting to Relational Databases on Heroku with Java for details.
  • JAVA_TOOL_OPTIONS: default JVM options based on dyno size

JAVA_TOOL_OPTIONS

JAVA_TOOL_OPTIONS is a standard JVM mechanism to set options in environments where the command line can’t be accessed or modified. Heroku sets this variable with default JVM options based on dyno size. Since Java automatically picks it up, you don’t need to include it in your Procfile command.

-Dfile.encoding=UTF-8 is always included in the defaults.

JAVA_TOOL_OPTIONS isn’t set for heroku run dynos to avoid interfering with processes that rely on clean standard output, such as MCP servers using the stdio transport.

You can override individual settings in your Procfile command. For example, to increase the maximum heap size:

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

You can also set your own JAVA_TOOL_OPTIONS config var. Your values are appended to the defaults and take precedence. Options you don’t override remain in effect.

Adjusting Environment for a Dyno Size

When you select a new dyno type, 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.

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
  • © 2026 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