Deploying Java.war application to Heroku

Do you know any tutorial on deploying a Java game application to Heroku or is it possible?



source to share

3 answers

You can run anything on Heroku. Therefore, you need to bring your own application server. The recommended way to do this is to list it as a dependency in the assembly descriptor. Then download the app and create a descriptor so that Heroku can build everything (dependencies and everything). But ultimately itโ€™s about you, how you get this stuff in Geroku.



In fact, sometimes using Google doesn't actually help. Deploying Java Hero War is a pain and the steps outlined are not all that great.

Basically heroku only runs simple Java processes, so you need to wrap your war file around your main java file. This blog post, Deploy the War on Heroku, describes some of the stages, and you also need to consult the heroku documentation to actually figure out the final hero push from git.

Here are the steps you need to follow (I assume you have your war file ready to go).

  • You need to build your jar file from your war file for it to include Jetty in it and it should be a running jar file. This is done in step 2.
  • Create a target assembler for your maven application in your pom.xml. The blog article provides an example snippet as well as other parts of the site. Let's say it's called mywebapp.jar. (it should be a can)
  • You now have a war file and you need to create a main program that loads this war file and creates a dock process. Remember heroku can only run java processes, so you are calling jetty as a direct process here. Take a look at the blog post for an example - for example, call this file.
  • Heroku requires a simple procfile, which is pretty much a template. For example:

web: sh target / bin / webapp

Upload everything to a git repository so you can easily push to hero - use this directory structure:

src/main/java/root -
src/main/resources - mywebapp.jar


Boom after this clicking on the hero (assuming you have a cedar stack that is set up like the hero link above).

git push heroku master


Happy hero. Also, as you can tell, this is too funny to deploy a war. If you are using heroku (as a paid client) please submit a feature request to make it better. Creating a runner class for your platform is a big no.



You can follow this post from my blog for a step-by-step explanation if you want to deploy a WAR file from your Spring MVC Web Application. I wrote it after trying and running my own application on Heroku.



All Articles