Community

New Cloudant Java Boilerplate on Bluemix

Share this post:

This was originally posted on the Cloudant.com blog but we wanted to ensure it received visibility to you here. The Cloudant team is thrilled to be the data layer behind Bluemix and we’re excited to have released a new IBM Bluemix boilerplate for building apps with Java and Cloudant. Cloudant has a lot of exciting updates coming for Bluemix users in the near future. Be on the lookout for more boilerplates, features, sample apps, and tutorials.

Related | Get Started with Cloudant on Bluemix

This tutorial will walk you through getting set up on IBM Bluemix and building your first app using the new Java boilerplate.

Prerequisites

  • You’ll need a Bluemix account. If you don’t already have one, go to https://ace.ng.bluemix.net/ and sign up in the top right corner.

  • You’ll also need to download ‘cf,’ the Bluemix command line tool. You can download it here.

  • Once you’ve signed in to Bluemix, navigate to the ‘catalog’ tab and click on the Java+Cloudant boilerplate

    Cloudant BlueMix Java Catalog

    You will then be taken to the initialization page for the boilerplate.

    Cloudant BlueMix Java Overview

    On the right-hand side you are asked to name your application. I’ve named mine “CloudantJavaTest’ so you can’t use that one, but pick something similar and then hit ‘Create.’

    Behind the scenes, Bluemix will provision space on its infrastructure for your application. The amount of space used depends on the app stack used. In this case, you will get 512MB of memory for this app. While Bluemix provisions space, Cloudant is creating a free account for you on one of our multi-tenant clusters.

    After creating your app you’ll be taken to the ‘Overview’ page where you will see your run time environment and your Cloudant instance in the ‘Development Services’ section.

    Cloudant BlueMix Java Overview

    You can easily find your Cloudant credentials by clicking ‘show credentials’ on the service tile or through VCAP_SERVICES (see below.) This Cloudant account acts like any other in that it has a username, password, and endpoint URL for its REST API. The only difference is that this account can be deleted from Bluemix if you delete your application.

    To view a quick-start guide for developing your app click the “View Guide” tab toward the top. (A fun pop-up will appear.) You will also see a link to download this app to your local machine for editing the code. The screen shot below is new, to show what it looks like in the updated Bluemix UI. So don’t be too confused if you’ve made it this far.

    Cloudant Bluemix Java Overview

    Within your application, your Cloudant credentials can be accessed through the VCAP_SERVICES environmental variable. You can see this variable in the Runtime tab

    Cloudant BlueMix Java Overview

    Within the boilerplate application code there is an example of how to access this variable in the runtime environment.

    Cloudant BlueMix Java Overview

    Once you’ve downloaded your application you can make any changes you would like to the code. When you are done, push the application back to Bluemix for building and running. To do so, you must first log in to Bluemix with cf:

    [code]$ cf login
    > username: <USERNAME>
    > password: <PASSWORD>[/code]

    then from the root directory of your application:

    [code]
    $ cf push
    [/code]

    This will build and push the application to Bluemix. You can visit the URL http://(yourappname).mybluemix.net and see the example app, which is a place to upload your favorite files (I use mine for useful gifs):

    Cloudant BlueMix Java Overview

    What’s Next?

    With this boilerplate you will have all the tools for building an app within Bluemix using the Java Runtime and linking it to Cloudant.

    We have many more exciting features, boilerplates, and tutorials revolving around Cloudant and Bluemix coming this year. Do you have anything you would like to see? Let us know!

    Learn More

    More stories
    January 18, 2019

    IBM Cloud Kubernetes Service Supports containerd

    For IBM Cloud Kubernetes Service clusters that run version 1.11 or later, containerd replaces Docker as the container runtime for Kubernetes.

    Continue reading

    January 18, 2019

    Strategies for Building Multi-Region Apps

    Enterprises seek to minimize downtime and create resilient architectures to achieve maximum availability. In order to help achieve those goals, we added a new tutorial to our collection of solution tutorials that highlights IBM Cloud's capabilities for building resilient solutions.

    Continue reading

    January 16, 2019

    Deploying Applications on IBM Cloud with Kubernetes and IBM Cloud Databases for PostgreSQL

    Deploying a cloud-native application and integrating IBM Cloud Databases is easy using the IBM Cloud Kubernetes Service. In this tutorial, we’ll show you how to set up IBM Cloud Databases for PostgreSQL and deploy a Node.js application using the database with the IBM Cloud Kubernetes Service.

    Continue reading