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
    November 14, 2018

    PostgreSQL Tips: Template Databases

    In this PostgreSQL Tip, we demystify PostgreSQL template databases and how and when you might use them. Template databases are really useful when you use the same database objects every time you create a new database.

    Continue reading

    November 9, 2018

    Build Messaging Solutions with Apache Kafka or Event Streams for IBM Cloud: Part 3

    One key aspect of a robust architecture is that it is built to smoothly handle system failures, outages, and configuration changes without violating the data loss and consistency requirements of the use case. To proactively build such solutions needs an understanding of the possible exceptions and risky scenarios and preparedness to manage them efficiently.

    Continue reading

    November 9, 2018

    How to Set Up a Concourse CI/CD Pipeline

    To hit the ground running for any project based on cloud-based applications, it is very important to set up the associated infrastructure for the development of microservices. Quick and high-speed development can be achieved if the team has a way to do Continuous Integration (CI) and Continuous Delivery (CD) of the application.

    Continue reading