How to migrate your Java Application from Heroku to


Migrate a Heroku Java Application to a service.


You will need:

  • an active application on configured to an empty database
  • an active application on Heroku


1. Git clone the Heroku Repository

git clone heroku_repository.git

2. Create the three basic file

3. Set the Application File

At the we’ll set the minimum configuration to run a plain configuration be aware that it does not include database services such as MySQL, MariaDB and so on.

# This file describes an application. You can have multiple applications
# in the same project.
# See
# The name of this app. Must be unique within a project.
name: app

# The runtime the application uses.
type: 'java:8'

disk: 1024

# The hooks executed at various points in the lifecycle of the application.
    build: mvn clean install

        source: local
        source_path: server_source

# The relationships of the application with services or other applications.
# The left-hand side is the name of the relationship as it will be exposed
# to the application in the PLATFORM_RELATIONSHIPS variable. The right-hand
# side is in the form `<service name>:<endpoint name>`.

# The configuration of app when it is exposed to the web.
        start: |
            cp target/dependency/webapp-runner.jar server/webapp-runner.jar
            cp target/tomcat.war server/tomcat.war
            cd server && java -jar -Xmx$(jq .info.limits.memory /run/config.json)m -XX:+ExitOnOutOfMemoryError webapp-runner.jar --port $PORT tomcat.war

4. Add Remote Repository

git remote add platform platform_repository.git

5. Push the changes to the Repository

git push platform master


By adding a file to a project, a Java application’s build process can be migrated from Heroku. In order to fully migrate, the next step is to use the Heroku CLI to dump your database and import it to a service defined on your project.

Additional resources: