Monday, 13 March 2017

Free Java hosting options and Heroku tomcat deployment

I wanted to write some java app that would communicate with 3rd party API. The main problem there was that this API requires https connection. So I needed free java hosting to test my concept.

I will describe my short research about free java hosting proposals. And will describe shortly Heroku quick start.

My main options were:
  • Amazon AWS - it is free for one year. It has EC2 - it is linux virtual machine solution and Elastic Beanstalk - it is like a pass with command line to interact. The main disadvanges for me that it doesn't have free SSL.
  • Digital Ocean - it is not free but gives you Linux virtual machine.
  • Cloudflare - PaaS, it has SSL and it is free. Unfortunately didn't have chance to try it.
  • Openshift - it is PaaS, i tried it couple of years ago and it was too complicated for simple apps.
  • Heroku - it is PaaS that has SSL support. What is most optimal option for me. Main disadvantage could be that it is idling your app each 30 minutes if it is inactive, but it was ok for me.

So here is few steps that need to be done to deploy you java app on Heroku tomcat server:

1) Need to install Heroku CLI it includes Git

2) need to create maven project with Procfile file in the root, it should contain:
web:    java $JAVA_OPTS -jar target/dependency/webapp-runner.jar --port $PORT target/*.war

3) Commit your chages to Git
git init
git add .
git commit -m "Ready to deploy"

4) Crete the app and & remote Git repo (of course login first with heroku login)
heroku create

5) Deploy your code
git push heroku master

6) Open your app url
heroku open


Also useful commands:
To show logs
heroku logs --tail

To enable scalling
heroku ps:scale web=1

To open bash console
heroku run bash

To see addons, add databse
heroku addons

To see config vars
heroku config


1 comment:

  1. Hi Sergey, thanks for the post! I was wondering if you'd had a chance to try deploying Tomcat on Azure? I'd like to hear your feedback about what could be better! Feel free to email me at or submit feedback through the tutorial link below (I monitor that feedback very closely!)

    You can see how to deploy Tomcat in the cloud for free here: