Getting started with a normal Java project can be a bit daunting but add in some of the latest things that developers want, such as microservices and cloud native, and the time to actually having something up-and-running has just gone up drastically!

Enter the new IBM Cloud Web and Mobile starters which allow you to quickly scaffold out a cloud native microservice. There are a number of languages to choose from: Java, Swift, and JavaScript/Node.js; a selection of patterns, such as microservice; and the opportunity to add in back-end services like Cloudant and Object-Storage.

The diagram below shows a high level view of the steps you take according to whether you prefer to use a GUI or a command line.

Overview of code creation to deployment

So, let’s create a Java microservice …

Step 1: choose your starting point

You can create a new Java microservice either through the IBM Cloud console, or using the new command line. To use the command line,

  1. Install the IBM Cloud CLI
  2. Install the developer plugin

If you’re using the IBM Cloud console, select the Create Project option. After that it is the same for both interfaces: select Microservice, Basic, and then Java.

Step 2: add some services

You can now add some data services to your project. Currently, you can pick from Cloudant or Object-Storage (or both if you want!). The really great thing is that these services will be provisioned automatically for you; no need to remember to create and bind them at a later point in time. Even better than that, the code that is generated for you will contain all the code you need to connect to these services using current best practices. So, in the case of the Java microservice, you will be given CDI injected connectors to your services all ready to be used in your code.

Step 3: download the code for local development

After making your selections, you’ll want to download the code and see what it looks like. If you’re using the CLI then this is automatically done for you; if you’re using the console, then you’ll need to click on the Generate Code button and then download it once it’s been created. At this point you can optionally do some local development on the code. A really cool feature here is that if you added services to your project in the previous steps, your local Java runtime will be using those cloud services rather than having to mock out the calls when running locally.

Step 4: deployment

There are a couple of ways you can now deploy your code to IBM Cloud. You can push it into a Github repository, at which point a Create toolchain button will appear: click on that and it will create a toolchain in IBM Cloud that pulls the code from your repository and deploys it. Alternatively you can use the CLI to run the bx dev deploy command that will deploy it for you. If you want to check on what’s been deployed, just use the IBM Cloud console.


This post is just a quick introduction and high level overview of how you can use the new code-generation capabilities in IBM Cloud to generate yourself a Java microservice and deploy it to the cloud. You can do this through the IBM Cloud console, using the command line, or even just mix and match the two. The choice is yours. Keep an eye out for future articles in which we’ll dive into the Java microservice in more detail, walking you through the actual classes that have been created and how you can use them as a basis for your own services. Finally, just explore and have fun playing with the new features, over time we’ll be adding more patterns, services, and microservices functionality. If you have any questions or suggestions, we’d love to hear them. Hang out with our team on the #cloud-native Slack channel and register at

2 comments on"Want a cloud native Java microservice? Read on…"

  1. You will need to run either the ‘bx dev build’ or ‘bx dev run’ commands, this will run the maven build which compiles the code and generates the artifacts to be deployed. I’ll feed back your experience to see if there is something we can do to highlight this step – although depending on the language generated, a prior build step may not be required.

  2. John Santoro March 25, 2017

    When I type bx dev deploy, I get an error that it cannot find \target in my project directory. Is there a step that I am missing after I generate the code using bx dev create?

Join The Discussion

Your email address will not be published. Required fields are marked *