Multiple Ways lead to Rome: How to deploy Java Applications to IBM Bluemix

The question that I’ve been asked most often recently by Java developers is how to deploy applications to Bluemix. There is a lot of good documentation available. Below is a quick overview with pointers to more detailed information. The different approaches have pros and cons dependent on the scenarios and personal preferences.

cf Tool
You can deploy Java applications (war and ear files) via the cf command line interface. This can be as easy as “cf push app_name -p app.war” where all additional parameters are defined in an additional manifest file. The Java code is built locally and the war file is deployed on Bluemix with the defined buildpack (Liberty by default).
I use this option sometimes as fallback when I have deployment issues and when I’m not sure whether it’s because of my code or potentially the other deployment tools. I can also use another cf logs command to see the logs easily during the deployment without having to go to another place.

Cloud Foundry Maven Plugin
When using the cf push command you need to build your code first. Personally I use Maven for all projects right now. You can use Maven from within Eclipse which comes with the M2Eclipse plugin. Alternatively you can build via the Maven command line tool.
Additionally there is an extension to Maven called the Cloud Foundry Maven Plugin which deploys the build to Bluemix directly. Check out the samples from Ryan Baxter how to do this.

Jenkins Cloud Foundry Plugin
If you’re using Jenkins as your continuous integration server you should check out the Jenkins Cloud Foundry Plugin which allows you to deploy your applications to Bluemix. I haven’t tried this one yet though.

Bluemix DevOps
Rather than building the code locally and then pushing the built code to Bluemix the Bluemix DevOps service can be used. In this scenario developers use Git to commit and push code to a source control repository on Bluemix or to GitHub and the code is both built and deployed on server side. In this case developers don’t have to set up and learn any additional tools which is why this option is especially interesting for short hackathons where people have little time. If you want to see this in action watch the demo I gave in a webinar recently or watch the videos from Lauren Schaefer.

Eclipse Tools
For many Java developers the easiest way to deploy applications to Bluemix is to use the Eclipse plugin. With this tool you can not only directly deploy projects to Bluemix but also debug code remotely, push incremental changes and even push the full Liberty server if you need a custom configuration.

So as you can see there are many options to deploy Java applications to Bluemix. I’ll update this blog entry when more options will become available.