Who uses Java on Heroku

Getting started with Java in Heroku

After completing this project, you will be able to perform the following tasks:

  • Create a Heroku account
  • Install the tools necessary to use Heroku
  • Build and deploy a Heroku application
  • Scale your Java application using Heroku tools
  • Modify and improve your Java application

Heroku is a PaaS (Platform-as-a-Service). With a PaaS, the complexity of building and operating a cloud infrastructure is abstracted away. With Heroku, you can deploy, manage and scale your applications without worrying about hardware or virtual machines. In this module you will learn how to get a real Java application up and running in Heroku in just a few steps.

Register for a Heroku account

To deploy an application in Heroku, create a free Heroku account by going to signup.heroku.com and providing some information. You do not need a credit card for the time being.

Prepare your development environment

This project requires a local installation of Java 8 or higher on your computer. If you do not have Java 8 installed, visit the Java SE Downloads website and select the correct version for your platform. If you want to check that the correct version is installed, run the command on your command line and check that you have version 8.0 or higher installed.

Next, install the Heroku CLI (Command Line Interface). You use the CLI to manage and scale your applications, deploy add-ons, view your application's logs as it runs in Heroku, and make it easier to run your application locally.

Finally, make sure that Git is installed and set up to run on your local machine.

Once installed, you can use the and commands from your command line. Enter and authenticate using the email address and password you provided when you created your Heroku account.

Authentication is required for the and commands to work.

If you are behind a firewall that requires the use of a proxy to connect to external HTTP / HTTPS services, you can set the HTTP_PROXY or HTTPS_PROXY environment variable in your local development environment before running the command.

Create and deploy an application in Heroku

Now you'll build a simple deployment application and run it in Heroku. First, duplicate the application repository so that you have a local version of the code. To do this, run the following two commands from your local command line or a terminal window:

mkdir heroku-java cd heroku-java git clone https://github.com/heroku/java-getting-started.git cd java-getting-started

You now have a working Git repository that contains a simple application and a file named that is used by the Java dependency manager Maven.

Now you will make your repository available for a Heroku application. Each Heroku application receives source code from a Git repository, like the one you created, and compiles it to run on the platform. Build a Heroku application by running the command.

When you create a Heroku application, a remote Git repository (named "") is also created and linked to your local Git repository. Heroku will generate an arbitrary name (in this case) for your application. You can also pass a parameter to define an application name yourself.

Now deploy your code by using the push command to push it to the Git Remote repository associated with your Heroku application.

When deployed correctly, the output should look something like this:

The application is now available. Make sure that at least one instance of the application is running.

Now visit the application at the URL generated by the application name. Handy shortcut: you can open the website from the CLI.

You will now see the Heroku template application in the browser. Congratulations! You are currently running your first web application on the Heroku cloud.

click on Verify Stepto go to the next step in the project.