---
"title": "Java"
"description": "Deploy modern JVM-based apps on the Heroku platform. Choose your preferred language or framework: Java, Scala, Groovy, Clojure, and many more."
"date": "2025-01-10"
"authors":
  -
    "name": "Heroku"
"url": "https://www.heroku.com/java/"
---

![Illustration of a round character wearing traditional samurai armor and helmet on an orange background, waving with one hand.](https://www.heroku.com/wp-content/uploads/2025/03/java-logo-hero.png)

# Deploy modern JVM-based apps

## Polyglot JVM Platform for modern apps

### Deploy

Deploy using Git, [GitHub](https://www.heroku.com/continuous-delivery/) or directly from your CI system using precompiled builds with tools like SBT or Maven. Regardless of how your source is delivered, Heroku runs it in a dyno – a smart, secure, curated container with your choice of JVM version.

### Manage

Manage your portfolio of apps in a single view using a straightforward Dashboard. Instantly see what version of your app is deployed and rollback to a stable version without recompiling. Manage your app’s environment specific configurations with external config vars.

### Scale

Heroku’s horizontally scalable, share-nothing architecture is perfect for apps built with modern frameworks like Play, that are async, stateless and non-blocking. Heroku makes scaling out or up as simple as dragging a slider in the Dashboard or using a single CLI command.

### Monitor

View detailed memory and garbage collection metrics in your Dashboard with JVM runtime metrics. Connect remote debuggers and inspection tools like VisualVM, or generate heap and thread dumps on demand to help track down even the most elusive bugs.

## Get started now with Java on Heroku

[Sign Up](https://signup.heroku.com/java)

[Video](https://youtu.be/PIetHURaWC0)

## Java/Spring

### Deploying Java apps with Heroku

- Initialize the local Git repository
- `CODE_OPEN`spring init`CODE_CLOSE` initializes the Java project
- Specify the Java version
- Create a Controller to respond to requests with “Hello Heroku!”
- Create and deploy the app to Heroku
- We’re live! `CODE_OPEN`curl https://morning-earth-85743-7d592a8d2dd3.herokuapp.com`CODE_CLOSE`

[View Java Docs](https://devcenter.heroku.com/categories/java)

## Scala/Play

### Deploying Scala apps with Heroku

- Initialize the local Git repository
- `CODE_OPEN`sbt new`CODE_CLOSE` initializes the Scala project
- Specify the Java version
- Generate a Play! application secret
- Configure Play! allowed hosts filter
- Create and deploy the app to Heroku
- We’re live! `CODE_OPEN`curl https://radiant-shelf-38588-bdcb08e1f9ef.herokuapp.com`CODE_CLOSE`

[View Scala Docs](https://devcenter.heroku.com/categories/scala-support)

[Video](https://youtu.be/AhOYLQnBt74)

[Video](https://youtu.be/2-bqZcmyTD4)

## Clojure

### Deploying Clojure apps with Heroku

- Initialize the local Git repository
- `CODE_OPEN`lein new`CODE_CLOSE` initializes the Clojure project
- Specify the Java version
- Create and deploy the app to Heroku
- We’re live! `CODE_OPEN`curl https://aqueous-beyond-75547-a50d4a181c24.herokuapp.com`CODE_CLOSE`

[View Clojure Docs](https://devcenter.heroku.com/categories/clojure-support)

## Why JVM Languages on Heroku?

### Choice of language and framework

Build microservices with Groovy and Ratpack, reactive APIs using Scala and Play, web apps with minimal fuss using Spark and high performance web apps with Spring Boot/Spring Cloud. Heroku provides buildpacks for Java, Scala, Play, Clojure, Gradle and Grails.

[Java on Heroku](https://devcenter.heroku.com/categories/java)

### Curated language stacks, intelligent defaults

Get early access to the latest JDK as soon as it’s available. Heroku runs your app on the latest stable version, Java 8, by default. Heroku sets intelligent defaults for your max heap size and stack size based on the size of the dyno smart container your app is running in.

[Heroku’s Java support docs](https://devcenter.heroku.com/articles/java-support)

### Extend your apps with 200+ Add-ons

Heroku add-ons like CloudAMQP, Postgres, Redis, Treasure Data (Hadoop as a service) and GrapheneDB (Neo4J as a service) allow you to extend, manage and deploy modern JVM-based applications without operational overhead.

[All Heroku Add-ons](https://elements.heroku.com/addons)

### Built-in debugging and inspection tools

Heroku’s [Metrics](https://devcenter.heroku.com/articles/metrics) dashboard helps you identify many kinds of performance problems, while key language specific metrics, like garbage collection activity and memory usage, are included in Heroku’s Language runtime metrics dashboard. After you’ve identified an issue, you can use [Heroku Exec](https://devcenter.heroku.com/articles/heroku-exec) to connect to a running dyno via SSH.

[Language runtime metrics docs](https://devcenter.heroku.com/articles/language-runtime-metrics)

## ![A red circle sits on top of a black, curved shape resembling an abstract letter A against a white background.](https://www.heroku.com/wp-content/uploads/2025/03/java-logo.png)

## Java on Heroku

> “Whether you are a business or a hobby developer, the JVM offers a mature and reliable platform to power your apps. You can choose the programming language that works best for the task at hand because of the ployglot nature of the JVM. Heroku offers extensive support for this ecosystem, enabling you to operate your business or side-project with confidence.”

![A person with dark hair looks down against a graffiti-covered wall.](https://www.heroku.com/wp-content/uploads/2025/03/avatar_manuelfuchs.png)

Manuel Fuchs

JVM Languages Owner

[@Malax](https://github.com/Malax)

### [Documentation](https://devcenter.heroku.com/categories/java)

- [WAR Deployment](https://devcenter.heroku.com/articles/war-deployment)
- [Deploying Java Applications with the Heroku Maven Plugin](https://devcenter.heroku.com/articles/deploying-java-applications-with-the-heroku-maven-plugin)
- [Deploying Scala and Play Applications with the Heroku sbt Plugin](https://devcenter.heroku.com/articles/deploying-scala-and-play-applications-with-the-heroku-sbt-plugin)
- [Deploying Gradle Apps on Heroku](https://devcenter.heroku.com/articles/deploying-gradle-apps-on-heroku)
- [Troubleshooting Memory Issues in Java Applications](https://devcenter.heroku.com/articles/java-memory-issues)
- [Heroku Exec](https://devcenter.heroku.com/articles/heroku-exec)
- [Language Runtime Metrics](https://devcenter.heroku.com/articles/language-runtime-metrics)

### [Tutorials & Help](https://devcenter.heroku.com/categories/java)

- [Getting Started with Clojure on Heroku](https://devcenter.heroku.com/articles/getting-started-with-clojure#introduction)
- [Getting Started with Java on Heroku](https://devcenter.heroku.com/articles/getting-started-with-java#introduction)
- [Getting Started with Scala/Play on Heroku](https://devcenter.heroku.com/articles/getting-started-with-scala#introduction)
- [Getting Started with Kotlin on Heroku](https://devcenter.heroku.com/articles/getting-started-with-kotlin#introduction)

## Popular Add-ons

Add-ons are fully-managed services, integrated for use with Heroku, which provide services for logging, caching, monitoring, persistence and more.
[View All Add-ons](https://elements.heroku.com/addons)

### [Heroku Kafka](https://elements.heroku.com/addons/heroku-kafka)

Data Stores

### [Heroku Postgres](https://elements.heroku.com/addons/heroku-postgresql)

Data Stores

![A geometric design with interlocking green and dark gray rectangular shapes forming a 3D-like structure on a white background.](https://www.heroku.com/wp-content/uploads/2025/03/newrelic.png)

### [New Relic APM](https://elements.heroku.com/addons/newrelic)

Monitoring

![Blue square with a white geometric logo featuring a three-dimensional shape composed of lines and angles.](https://www.heroku.com/wp-content/uploads/2025/03/rollbar.png)

### [Rollbar](https://elements.heroku.com/addons/rollbar)

Errors and Exceptions

## Heroku Java Support FAQ

### How does Heroku manage Java dependencies?

Heroku automates Java dependency management by using your project's build tool. While the default build system is **Maven**, Heroku also provides full support for **Gradle**. During deployment, the buildpack detects your build file (`pom.xml` for Maven or `build.gradle` for Gradle) and automatically runs a build. This process downloads all the required dependencies from their respective repositories (like Maven Central) before compiling your code, ensuring a reliable and repeatable build.

### What is the fastest way to deploy a sample Java application to Heroku?

The fastest way to get started is by following the official [**Getting Started on Heroku with Java**](https://devcenter.heroku.com/articles/getting-started-with-java) guide in the Heroku Dev Center. This tutorial provides a sample application and walks you through the steps of cloning the repository, provisioning a Heroku app, and deploying your code with a simple `git push heroku main` command.

### Which Java versions are supported on Heroku?

Heroku’s policy is to support all Java versions that are not End-of-Life (EOL), including all current non-EOL Long-Term Support (LTS) releases of the OpenJDK.

You can specify your desired Java version by creating a `system.properties` file in the root of your application and setting the `java.runtime.version` property. For example, to use Java 21, your file would contain: `java.runtime.version=21`.

It is strongly recommended to always explicitly configure the required version for your application. If you don’t, the default version will be used, which can change over time and may cause future builds of your application to fail.

### What are the most popular Java frameworks to deploy on Heroku?

Heroku supports a wide variety of frameworks from the Java ecosystem, from established leaders to modern, cloud-native options. The most popular choice is [**Spring Boot**](https://devcenter.heroku.com/articles/deploying-spring-boot-apps-to-heroku), which is excellent for building everything from monolithic applications to microservices. Additionally, cloud-native frameworks like **Quarkus** and **Micronaut** are increasingly popular on the platform due to their fast startup times and low memory footprints.

### Does Heroku support both Maven and Gradle for building Java applications?

Yes. Heroku provides full support for both **Maven** and **Gradle**, with Maven being the default build tool for Java applications. During deployment, the buildpack automatically detects which build tool your project is using by looking for either a `pom.xml` file (for Maven) or a `build.gradle` file (for Gradle) in your project's root directory. This auto-detection means you don't need any special configuration to use your preferred build tool.

### Do I need to compile my Java code and build a JAR file before deploying to Heroku?

No. For a standard deployment, you should push your Java source code directly to Heroku. The platform is designed to handle the entire build process for you. When you deploy, the Java buildpack runs your build tool (**Maven** or **Gradle**) to compile your code and create a runnable application. This source-based workflow ensures a clean and repeatable build every time and means you don't need to commit compiled artifacts to your Git repository.

For workflows that require building on your own infrastructure, Heroku also provides tools to deploy pre-built JAR or WAR files directly.

### Can I deploy applications written in other JVM languages like Scala, Kotlin, or Clojure on Heroku?

Yes. Heroku's Java support is fundamentally support for the Java Virtual Machine (JVM). This means that any language that compiles to JVM bytecode and uses a standard build tool like **Maven**, **Gradle**, **sbt**, or **Leiningen** can be deployed on the platform. This includes popular JVM languages like [**Scala**](https://devcenter.heroku.com/articles/scala-support), [**Clojure**](https://devcenter.heroku.com/articles/clojure-support), and **Kotlin**. You can manage your project with a `pom.xml` or `build.gradle` file just as you would with a standard Java application, and Heroku's buildpack will handle the rest.

## Ready to Get Started?

Stay focused on building great data-driven applications and let Heroku tackle the rest.

[Sign Up Now](https://signup.heroku.com/)