Heroku Java Support Reference
Last updated December 03, 2024
Table of Contents
Heroku can run Java applications across a variety of Java implementations and includes support for framework-specific workflows. This document contains version support info.
For general behavior info of Heroku recognizes and executes Java applications, see Heroku Java Behavior. General Java support on Heroku refers to the support for all frameworks.
For framework-specific tutorials, see:
- Getting Started on Heroku with Java (Maven)
- Getting Started on Heroku with Java (Gradle)
- Java Tutorials
Specifying a Java Version
We recommend always explicitly configuring the required OpenJDK major version for your application. If you don’t configure a version, the default version for the stack is installed. The default version will change over time and your application might fail to build with the new default version.
The current default versions for each stack are:
heroku-20 |
heroku-22 |
heroku-24 |
---|---|---|
OpenJDK 8 | OpenJDK 8 | Latest LTS (currently OpenJDK 21) |
To explicitly configure the OpenJDK version, add a file called system.properties
to your application. Within that file, set the java.runtime.version
property to the OpenJDK major version for your app:
java.runtime.version=11
See the supported Java versions table for accepted major versions.
You can also pin your OpenJDK version to a full version. We don’t recommend this, unless there is a strong reason to do so. Pinning to a full version will cause your app to not automatically get OpenJDK security updates on each build.
To use a full version, set the java.runtime.version
property to the full version string:
java.runtime.version=1.8.0_412
Supported Java Versions
Refer to the table for the latest available version for each OpenJDK major version and Heroku stack. The selected OpenJDK version is bundled with your app and affected the final app size.
Rows marked up with red text and background indicate an OpenJDK version that is fully end-of-life and no longer receiving updates of any kind from the upstream maintainers and is no longer supported by Heroku.
OpenJDK Version | heroku-20 |
heroku-22 |
heroku-24 |
---|---|---|---|
OpenJDK 7 | 1.7.0_352 | 1.7.0_352 | - |
OpenJDK 8 | 1.8.0_432 | 1.8.0_432 | 1.8.0_432 |
OpenJDK 11 | 11.0.25 | 11.0.25 | 11.0.25 |
OpenJDK 13 | 13.0.14 | 13.0.14 | - |
OpenJDK 14 | 14.0.2 | - | - |
OpenJDK 15 | 15.0.10 | 15.0.10 | - |
OpenJDK 16 | 16.0.2 | - | - |
OpenJDK 17 | 17.0.13 | 17.0.13 | 17.0.13 |
OpenJDK 18 | 18.0.2.1 | 18.0.2.1 | - |
OpenJDK 19 | 19.0.2 | 19.0.2 | - |
OpenJDK 20 | 20.0.2 | 20.0.2 | - |
OpenJDK 21 | 21.0.5 | 21.0.5 | 21.0.5 |
OpenJDK 22 | 22.0.2 | 22.0.2 | 22.0.2 |
OpenJDK 23 | 23.0.1 | 23.0.1 | 23.0.1 |
Specifying an OpenJDK Distribution
Heroku supports builds of OpenJDK from either Azul® Zulu® or Heroku. Both distributions are built from the same source and are fully compliant with the Java SE specification. Azul® Zulu® builds of OpenJDK are also TCK/JCK certified and are our recommended OpenJDK distribution.
Heroku’s builds of OpenJDK are only available for Cedar-generation apps.
The default distributions of OpenJDK for each stack are:
heroku-20 |
heroku-22 |
heroku-24 |
---|---|---|
Heroku | Azul® Zulu® | Azul® Zulu® |
Using a Non-default Distribution
To use a non-default distribution with your app, you must specify a Java version. Prefix the version string with either heroku-
or zulu-
to select the respective distribution.
To use OpenJDK 11 and explicitly select Azul® Zulu® as the OpenJDK distribution, add the following to system.properties
:
java.runtime.version=zulu-11
Upgrading Your Java Version
When you deploy a Java app, the app automatically upgrades to the latest available OpenJDK version. The version doesn’t upgrade if you don’t redeploy the app or if you don’t configure a specific version in the system.properties
file.
Specifying a Maven Version
Heroku supports the Maven Wrapper, which is the recommended mechanism for defining a Maven version. If Heroku detects an mvnw
file in the root directory of your repository, it uses this script to launch the Maven process.
You can also specify a Maven version with the system.properties
file by setting a maven.version
property:
maven.version=3.9.4
If you define this property, Heroku ignores the mvnw
script. We don’t upgrade your app to a new version automatically and you must update your system.properties
file to get a new version.
The default version, if you don’t specify a version and don’t use Maven Wrapper, is 3.9.4
. This default changes over time and we recommend using Maven Wrapper to ensure stable builds.
See the Working with Maven category for more info on Maven.
Default Web Process Type
The Java buildpack automatically detects the use of the Spring Boot web framework. For Spring Boot, it creates a web
process type with the following command:
java -Dserver.port=$PORT $JAVA_OPTS -jar target/*.jar
You can override this default or define a custom process type using a Procfile
. The appropriate command depends on your app and the frameworks in use. See one of the Java tutorials for information on setting up your Procfile
.
Behavior
See Heroku Java Behavior behavior info.
Customer Support
You can submit issues via one of the Heroku Support channels.