Public Static[] Void Main and ClickStacks

Written by: Michael Neale
3 min read

So as you have heard about, or will probably hear about - we recently announced a feature called "ClickStacks" which complement our ClickStart feature. ClickStacks allow us to easily support many varied frameworks and runtimes.

One of the most asked for and long awaited features is the ability to launch a plain old JVM application (e.g., an executable JAR, or an app and specify the main class) - and that is now available.

Why would you want to do this? Well, here are a few good reasons:

  • You want to programmatically wire up your own container

  • You want to use a specific version of Jetty/Netty/container of your choice

  • You don't want to use a servlet container or app server

  • You want to deploy your app as a self-contained bundle/executable

Many modern deployments fit into one of the above - and that is just perfectly fine.

This works with any and all JVM apps - regardless of the language they are compiled from. A popular use of this is for people to deploy their app with an embedded "container" - it is quite common to do Jetty this way. We do Play 2 this way (Play 2 uses Netty - so we specify the main class to launch it and load up the class path).

One of the easiest ways is to take a look at this ClickStart here .

The details on how to use: you can specify the container type (-t on the bees CLI) as "Java" - the package can then be a zip of JAR files, or an executable JAR itself. If it is a bunch of JAR files - you will want to set -Rclass to the main class you want to launch (eg -Rclass=com.yourco.App). You can also specify the classpath (eg -Rclasspath=somename/lib/* - to include all JARs in the lib directory).

If you are listening on a port for http, the $app_port environment variable will tell you what to listen on (e.g., if you are wiring up a Jetty server programmatically) - and have all "log" messages go to stdout and stderr (where we will catch them). The rest is basically up to you to do what you want!

ALSO, select your JVM: -Rjava_version=1.7 (versions are 1.6, 1.7 and 1.8!)

You get all the rest of the benefits of the CloudBees platform, but with your own hand-crafted app container/deployment unit.

TL;DR: CloudBees lets you run Java main apps, deploy ZIP or JAR files, or a JAR file.

Michael is an open source polyglot developer. For his sins he spent time at JBoss, working on the Drools project, and then Red Hat, where he continually caused trouble on various projects. His interest in the cloud is natural, as he is attracted to disruptive technologies. Michael lives and works in the Blue Mountains, just outside Sydney, Australia.

Follow Michael's daily struggle on his blog .

Stay up to date

We'll never share your email address and you can opt out at any time, we promise.