Challenge Java EE !

Java EEを中心に趣味や仕事における開発メモを書いています。

PayaraMicro on Heroku !

I'm newbie both Payara and Heroku. Though I tried to play with these for preparing my presentation in Japanese GlassFish User Group event.

About one month ago, I participated Japanese Salesforce event. It was called "Salesforce Summer"

At the event, I saw Heroku demonstration. This is the reason why I started to use Heroku.After the event, I checked Heroku site and found good Java tutorial. In the tutorial, the sample Java web application used Spark.

I thought that ... if I use Payara Micro, is it possible to deploy Java EE application to Heroku ?

Finally, it could. Here is procedures.

Getting Started with Java on Heroku

Firstly, I started "Getting Started with Java on Heroku". The tutorial is very polite, so it's easy to do.

  • Installing Toolbelt (for Windows on my environment)
  • heroku login

After that, I cloned "java-getting-started" from github.

git clone

And changed directory.

cd java-getting-started


heroku create
git push heroku master
heroku ps:scale web=1
heroku open

Finally I confirmed the deployed page.


These procedures are same as the tutorial.

PayaraMicro on Heroku

I used the same project, it means I used "java-getting-started" project cloned from GitHub.
It's kind of cheat I think. Normally, it had better create as new project.

Firstly, I changed pom.xml.


Also, I edited the code like this.

import fish.payara.micro.BootstrapException;
import fish.payara.micro.PayaraMicro;

public class Main {
  public static void main(String[] args) throws BootstrapException {

It's very important to call "setHttpPort(Integer.parseInt(System.getenv("PORT")))", because the port of HTTP on Heroku is binded random.

If that helps, I used NetBeans IDE.


After changing code, I copied from WAR file which is target of deploy to this project.
The War was created by Java EE 7, but I used only JSF and CDI.

Finally, I committed the code and "git push heroku master". Everything was done.

Here is my deployed Java EE app with PayaraMicro on Heroku :)


にほんブログ村 IT技術ブログへ
にほんブログ村 にほんブログ村 IT技術ブログ Javaへ