Creating First Application in Heroku using Eclipse

Hello Readers, in this article we will see step by step procedure to deploy your first (Hello World) program in Heroku. There are two ways, first going through series of Commands of “Heroku” and “GIT” and other simple and smart way is to use Eclipse Capability with Heroku. To make things easier we will go by second method.

!Deprecated!

This tool / blog post is deprecated. Please follow this guide to deploying applications to Heroku from Eclipse. If you still want to follow this post, then download Eclipse plugin for Heroku from here.

Prerequisites:

Installation and Set up:
First we will need to Install Heroku Plugin in Eclipse. To install it, Navigate to “Help | Install New Software” and click on “Add” button.

Give any name in website like “Heroku Plugin” and enter this URL in Location https://eclipse-plugin.herokuapp.com/install and click on “Ok” and Finish Installation. It will install the Heroku Plugin required to start your first Plugin.

Next step is setting up your Credentials for Heroku :

Navigate to “Window | Preferences | Heroku”, Here either enter your UserName and Password of Heroku Account and click on “Login” or enter you API key, which you can find by logging into your Heroku Account.

Setting up Credentials for Heroku in Eclipse
Setting up Credentials for Heroku in Eclipse


Creating SSH Key :

Heroku uses Git to push and pull code from Heroku. For this you can use E-Git plugin of Eclipse. You can also visit this article for complete tutorial. So, for communication between Heroku and Git we need SSH. Navigate to “Windows | Preferences |General | Network Connections | SSH2 “. Navigate to “Key Management“ tab and click on “Generate RSA Key”. After Generation of key click on “Save Private Key”.

Generate SSH Key in Eclipse for Heroku
Generate SSH Key in Eclipse for Heroku

Now, after generation of RSA key Navigate to “Heroku” and click on “Load SSH Key” and select file which you have saved recently.

Load SSH Key in Heroku using Eclipse
Load SSH Key in Heroku using Eclipse

Now, till this we have done all the configurations. Start with creating our first “Hello World” program from Template using Jetty.
Navigate to “New | Project | Heroku | Create Heroku App from Template” and click on Next.

Select Application template from new Heroku Project
Select Application template from new Heroku Project

On Next screen select “Embedded Jetty-Servlet application” and click on Finish. After creation of sample project, open “Main.java” file and run it.

Now open browser with URL http://localhost:8080/ and you should able to see Jetty Page. If you are able to see the Jetty Startup page, means everything is good. Now navigate to http://localhost:8080/hello , you will see text “Hello Heroku” just like below screen.

Getting Started with Embedded Jetty in Heroku
Getting Started with Embedded Jetty in Heroku

You can make modifications in “HelloServlet.java” by replacing below line with some other Text.

<br />out.write("Hello Heroku".getBytes());<br />

Deploying Modifications to Heroku from Local System:

Now, as we are done with making modifications in local code, commit the changes in Git by “Right Click on Project | Team | Commit”. You need to Enter Commit Message like this:

Commit Changes to Git - Heroku
Commit Changes to Git – Heroku

After Committing the Changes, Navigate to “Right Click on Project | Team | Push to Upstream”.

Push to UpStream in Git for Heroku
Push to UpStream in Git for Heroku

Now, if everything is good, Heroku will receive all you local Changes and build application again on its server.

Heroku Build Succeed
Heroku Build Succeed

Now you can run this application by logging into Heroku and make modifications that’s suits you like Salesforce Integration or any other.

You can also visit this official Heroku tutorial, which explains in very detail about Heroku Deployment using Eclipse and other important Configurations.

If you are getting an error “eclipse SSH key is not matching the SSH key(s) that is associated with your Heroku account“, then follow this article to resolve this.

Posted

in

,

by


Related Posts

Comments

6 responses to “Creating First Application in Heroku using Eclipse”

  1. Zainab Avatar
    Zainab

    Hi,
    I tried to install the plugin on Eclipse 3.8.2 and 4.2.2, but in both cases, i cannot find heroku under Window >Preferences.

    I did not face any issues while installing the plugin either. I am really stumped as i cannot progress and set up the API key to continue with my project.

  2. SFDCChennai Avatar
    SFDCChennai

    Hi,

    After this step,On Next screen select “Embedded Jetty-Servlet application” and click on Finish.

    Im getting SSH Key is not correct.I followed same as you had given..and I got the mail too with the SSH key.
    wonderring why for me,getting SSH key is not matching,checkin in preference..

    Please help me out..

    1. JitendraZaa Avatar
      JitendraZaa

      Have you properly installed Egit Plugin

  3. Aman Avatar
    Aman

    Hi,
    I have installed all the plugins but when i am creating project with Heroku , it shows heroku error.

    java.lang.reflect.InvocationTargetException

    Any idea or help would be highly appreciated.

    -Aman

  4. Sandeep Kumar Avatar
    Sandeep Kumar

    Hello,

    I feel your stuff is cool to follow.

    I’m finding tough to get the heroku plugin. As the link above doesn’t work

    Thanks in advance.

    1. Jitendra Zaa Avatar

      This post was written long back. Unfortunately, this is depreciated and not supported by Heroku. Still if you want to try then download plugin manually from here – https://github.com/heroku/heroku-eclipse-plugin

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Jitendra Zaa

Subscribe now to keep reading and get access to the full archive.

Continue Reading