IntelliJ IDEA 2017.1 Help

Getting Started with Heroku

This feature is supported in the Ultimate edition only.

This tutorial illustrates main tasks related to working with Heroku.

Creating a Heroku user account

Go to the Heroku web site and sign up for a user account.

Generating and installing SSH keys

To be able to deploy your code to the cloud, you have to upload your public SSH key to Heroku. You can do that, for example, when registering your Heroku user account in IntelliJ IDEA.

If you don't have a private/public SSH key pair, generate one. Search the Internet for corresponding tools and instructions.

Put your keys to the .ssh folder in your user home directory.

Making sure that Heroku and Git Integration plugins are enabled

To be able to work with Heroku and Git on Heroku, the Heroku Integration and the Git Integration plugins must be enabled. To make sure that these plugins are enabled, use the Plugins page of the Settings/Preferences dialog (Ctrl+Alt+S | Plugins).

Registering your Heroku user account in IntelliJ IDEA

  1. Open the Settings/Preferences dialog (e.g. Ctrl+Alt+S) and select Build, Execution, Deployment | Clouds .
  2. Click /help/img/idea/2017.1/new.png and select Heroku.
  3. Specify your user name and password.
  4. If you haven't uploaded your public SSH key to Heroku yet, you can do that now.

    Click Upload Public SSH Key and select the key file in the dialog that opens.

    The key file should have the .pub extension and may be called, or something similar.

  5. Click OK.

Creating a project

  1. Click Create New Project on the Welcome screen, or select File | New | Project on the main menu.

    The New Project wizard opens.

  2. In the left-hand pane, select Clouds. The rest of the settings should be similar to this:

    Click Next.

  3. Specify the name for your new project (e.g. MyFirstAppForHeroku).

    Click Finish.

Exploring a run configuration

To deploy and debug your applications on Heroku, IntelliJ IDEA provides Heroku Deployment run/debug configuration.

There is already one such configuration in your project.

Let's take a quick look at its settings.

  1. Select Run | Edit Configurations.

    The run/debug configuration specifies that your module source code should be deployed to Heroku. (MyFirstAppForHeroku is the name of a module.)

    The application will be deployed under its default name, in this case, myfirstappforheroku. (The application name defines its URL, https://<app-name> If you want to use a different name, select the Use custom application name check box and specify the name.

    If you wanted to use the run configuration also for debugging your app, you'd specify the debug host and port.

    To create another run configuration for Heroku, you should click /help/img/idea/2017.1/new.png and select Heroku Deployment. For more information, see Working with Run/Debug Configurations and Run/Debug Configuration: Heroku Deployment.

  2. Click OK.

Deploying your app

  1. Start the run configuration: click /help/img/idea/2017.1/run.png to the right of the run configuration selector or press Shift+F10.

    The Commit and Push dialog opens. This dialog is used to commit changes to your local Git repository and to push them to a remote Git repository, in this case, the one on Heroku.

  2. Write the commit message and click Push without Commit.

    As a result (all the following takes place on Heroku; you can monitor the process in the Application Servers tool window):

    • A Git repository for your app source code is created.
    • The app dependencies specified in pom.xml are installed.
    • Your app is built and started.

    Finally, when your app is deployed, the link to it is shown within the line Application is available at ...

  3. Click the link.

    Your web browser opens and your application output is shown.


Modifying the source code

  1. Open the file index.jsp for editing: select the file in the Project tool window and press F4.
  2. Change the text, say, to Hello from IntelliJ IDEA!

Redeploying the app

To publish the changed version of your app, you should redeploy the app.

  1. In the Application Servers tool window, right-click your app and select Redeploy.
  2. In the Commit and Push dialog, write the commit message and click Commit and Push.
  3. When the message '<app-name>' has been deployed successfully is output, switch to the web browser and reload the page to see the changes.

Undeploying the app

When your app is no longer needed, you should undeploy it (i.e. remove it from Heroku along with its source code).

  1. In the Application Servers tool window, right-click your app and select Undeploy.
  2. Provide your Heroku password to confirm your intention to delete the app.
  3. Switch to the web browser and reload the page to see that you app has become unavailable.

Disconnecting from Heroku

  • In the Application Servers tool window, right-click Heroku and select Disconnect.

See Also

Last modified: 18 July 2017