Skip Navigation
Show nav
Heroku Dev Center
  • Get Started
  • Documentation
  • Changelog
  • Search
  • Get Started
    • Node.js
    • Ruby on Rails
    • Ruby
    • Python
    • Java
    • PHP
    • Go
    • Scala
    • Clojure
  • 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 inorSign up
View categories

Categories

  • Heroku Architecture
    • Dynos (app containers)
    • Stacks (operating system images)
    • Networking & DNS
    • Platform Policies
    • Platform Principles
  • Command Line
  • Deployment
    • Deploying with Git
    • Deploying with Docker
    • Deployment Integrations
  • Continuous Delivery
    • Continuous Integration
  • Language Support
    • Node.js
    • Ruby
      • Working with Bundler
      • Rails Support
    • Python
      • Background Jobs in Python
      • Working with Django
    • Java
      • Working with Maven
      • Java Database Operations
      • Working with the Play Framework
      • Working with Spring Boot
      • Java Advanced Topics
    • PHP
    • Go
      • Go Dependency Management
    • Scala
    • Clojure
  • Databases & Data Management
    • Heroku Postgres
      • Postgres Basics
      • Postgres Getting Started
      • Postgres Performance
      • Postgres Data Transfer & Preservation
      • Postgres Availability
      • Postgres Special Topics
    • Heroku Redis
    • Apache Kafka on Heroku
    • Other Data Stores
  • Monitoring & Metrics
    • Logging
  • App Performance
  • Add-ons
    • All Add-ons
  • Collaboration
  • Security
    • App Security
    • Identities & Authentication
    • Compliance
  • Heroku Enterprise
    • Private Spaces
      • Infrastructure Networking
    • Enterprise Accounts
    • Enterprise Teams
    • Heroku Connect (Salesforce sync)
      • Heroku Connect Administration
      • Heroku Connect Reference
      • Heroku Connect Troubleshooting
    • Single Sign-on (SSO)
  • 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
  • Deployment
  • Deployment Integrations
  • Deploying Executable JAR Files

Deploying Executable JAR Files

English — 日本語に切り替える

Last updated May 25, 2020

Table of Contents

  • Using the Heroku Java CLI plugin
  • Using the Heroku Maven plugin
  • Deployment with Git
  • Deploying Scala fat jars
  • Deployment with Scala, Clojure and Gradle
  • Further reading

Many Java and JVM applications are packaged into a self-contained executable JAR file that includes application code, configuration and dependencies. These artifacts are often called “uberjars” or “fat jars”.

This article shows several different techniques for deploying a fat JAR to Heroku.

Using the Heroku Java CLI plugin

The Heroku Java CLI plugin can deploy a pre-built JAR file with very little set up or dependencies. To use it, you must have created a Heroku account and installed the Heroku CLI. Then run this command to install the plugin:

$ heroku plugins:install java

Then create an application:

$ heroku create --no-remote

And deploy your JAR file by running this command, replacing the app name (sushi in this case) with the app name generated by the previous command:

$ heroku deploy:jar target/my-app.jar --app sushi

You can customize the execution of the JAR file by creating a Procfile or including additional files in the deployment.

Using the Heroku Maven plugin

The Heroku Maven Plugin can be used as described in Deploying Java Applications with the Heroku Maven Plugin, but with the following configuration:

<includeTarget>false</includeTarget>
<includes>
  <include>target/my-app-1.0.jar</include>
</includes>

Then configure your process types to execute the JAR by adding some configuration like this:

<processTypes>
  <web>java -jar target/my-app-1.0.jar</web>
</processTypes>

You can customize the deployment as described in Deploying Java Applications with the Heroku Maven Plugin.

Deployment with Git

When you deploy your source code to Heroku with git push heroku master (as described in Deploying with Git), your JAR file will be included in your app’s slug. You only need to define how to run it in the app’s Procfile. For example:

web: java -jar target/myapp.jar

Make sure you add your Procfile changes to your Git repository.

Deploying Scala fat jars

The sbt-heroku plugin has built-in support for sbt-assembly, which is the de facto tool for building Scala fat JAR files.

If you are packaging your application with sbt-assembly, you can deploy that file by adding the following configuration to your build.sbt:

herokuFatJar in Compile := Some((assemblyOutputPath in assembly).value)

If not using sbt-assembly, you may replace (assemblyOutputPath in assembly).value with the relative path to your JAR file. Then you can deploy by running:

$ sbt assembly deployHeroku

The sbt-heroku plugin will skip the default sbt-native-packager execution and deploy your JAR directly to Heroku.

Deployment with Scala, Clojure and Gradle

Other JVM languages have support for deploying executable JAR files on Heroku. For more information see:

  • Gradle: Deploying Gradle Apps on Heroku
  • Clojure: Uberjar deployment with Git

Further reading

See Deploying Java Applications to Heroku from Eclipse or IntelliJ IDEA to learn how to deploy from Eclipse, IntelliJ or a CI Server.

Keep reading

  • Deployment Integrations

Feedback

Log in to submit feedback.

WAR Deployment Deploying Java Applications to Heroku from Eclipse or IntelliJ IDEA

Information & Support

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

Language Reference

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

Other Resources

  • Careers
  • Elements
  • Products
  • Pricing

Subscribe to our monthly newsletter

Your email address:

  • RSS
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku Blog
    • Heroku News Blog
    • Heroku Engineering Blog
  • Heroku Podcasts
  • Twitter
    • Dev Center Articles
    • Dev Center Changelog
    • Heroku
    • Heroku Status
  • Facebook
  • Instagram
  • Github
  • LinkedIn
  • YouTube
Heroku is acompany

 © Salesforce.com

  • heroku.com
  • Terms of Service
  • Privacy
  • Cookies
  • Cookie Preferences