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 ).
Registering your Heroku user account in IntelliJ IDEA
- Open the Settings/Preferences dialog (e.g. Ctrl+Alt+S) and select .
- Click and select Heroku.
- Specify your user name and password.
- 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
.pubextension and may be called
id_dsa.pubor something similar.
- Click OK.
Creating a project
- Click Create New Project on the Welcome screen, or select on the main menu.
The New Project wizard opens.
- In the left-hand pane, select Clouds. The rest of the settings should be similar to this:
- Specify the name for your new project (e.g.
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.
The run/debug configuration specifies that your module source code should be deployed to Heroku. (
MyFirstAppForHerokuis 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>.herokuapp.com/.) 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 and select Heroku Deployment. For more information, see Working with Run/Debug Configurations and Run/Debug Configuration: Heroku Deployment..
- Click OK.
Deploying your app
- Start the run configuration: click 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.
- 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
- 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 ...
- Click the link.
Your web browser opens and your application output is shown.
Modifying the source code
- Open the file
index.jspfor editing: select the file in the Project tool window and press F4.
- 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.
- In the Application Servers tool window, right-click your app and select Redeploy.
- In the Commit and Push dialog, write the commit message and click Commit and Push.
- 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).
- In the Application Servers tool window, right-click your app and select Undeploy.
- Provide your Heroku password to confirm your intention to delete the app.
- 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.