Table of Contents
This article only applies to applications in Heroku Enterprise for Java packages.
In addition to deploying with Git, Heroku also supports deploying Java web applications as WAR files from either Eclipse or the command line. When deploying with these methods, the WAR file is automatically placed in a Tomcat 7 web application container and deployed as a Heroku application. WAR deployments are subject to the same slug size limits as Git-based deployments.
If you have questions about Java on Heroku, consider discussing them in the Java on Heroku forums.
See Getting Started with Heroku and Eclipse to install and configure the Heroku Plugin for Eclipse.
Create a WAR file to deploy. Any method can be used to generate a WAR file. You can use Maven, Ant, or export directly from Eclipse. The only requirement is that the WAR file is a standard Java web application and adheres to the standard web application structure and conventions. In Eclipse, there are two methods commonly used to generate WAR files, depending on the project type:
- Dynamic Web Project: Right-click the project | Export | WAR File. You will be prompted for the export location.
Maven WAR Project: Right-click the project | Maven build… | Goals:
package| Run. The WAR file will be created in the project’s
Right click on the target application in the My Heroku Apps view.
Click on Deploy…
Choose the WAR file created in Step 1 to deploy.
The WAR file will be uploaded and deployed to Heroku
- Install the Heroku Toolbelt
- Install the
heroku-deploycommand line plugin:
$ heroku plugins:install https://github.com/heroku/heroku-deploy
Create a WAR file to deploy. Any method can be used to generate a WAR file. You can use Maven, Ant, or simply export your application from your IDE as a WAR file. The only requirement is that the WAR file is a standard Java web application and adheres to the standard web application structure and conventions. For example, if the application is a Maven project with
mvn packagewill generate a WAR file in the project’s
Deploy the WAR file:
$ heroku deploy:war --war <path_to_war_file> --app <app_name>
If you are in an application directory, the
--app parameter can be omitted:
$ heroku deploy:war --war <path_to_war_file>
WAR files are deployed to your application with Tomcat 7 using Webapp Runner. Webapp Runner allows advanced options, such as session management and custom Tomcat config files, to be configured. To configure Webapp Runner for deployed WAR files, set the value of the
WEBAPP_RUNNER_OPTS config var on your app, and it will be passed to Webapp Runner on start up. For example, to configure a Memcached session store, set
In Eclipse, config vars can be set by right-clicking on the app name in the My Heroku Application | App Info | Environment Variables.
On the command line, run the following:
$ heroku config:set WEBAPP_RUNNER_OPTS="--session-store memcache"