Wednesday, May 4, 2016

Working with Bluemix

This Developer Hat article is not really about coding.  It's more about how to easily use Bluemix to get started, and then build, deploy and run a Java application in the cloud.  For me, this would have been a fairly trivial exercise if I were developing a WAS app on my desktop.  But I imagined getting it deployed to the cloud was going to be hard.  I was wrong.

So today I wanted to write a simple app in Java, only because I know Java better than I know node.js or other languages.  The first step, is to search Bluemix for a starting point, and since I wanted something quick and dirty I just I started with a simple WAS Liberty Profile and a simple servlet.

Bluemix guides you pretty well, explaining how to download your sample code as well as the CF and Bluemix command line utilities.  I installed the utilities, and unzipped the sample code to my workspace. Even though I already have umpteen copies of Eclipse sitting around, Bluemix tells me I will need the Mars version and some add-ons, IBM Eclipse Tools for Bluemix and Liberty profile V8.5.5.5 (or later) runtime 

I already have Liberty up and running for some other projects I'm working on, so I skipped that one. And just pulled down Mars and the Tools for Bluemix.

Opened the new Eclipse, Import Existing Projects and pointed at the sample code I pulled from Bluemix.  I found the sample servlet class.  Made my changes.  Verified the descriptor.  Saved the WAR file.

I had to edit the YML file.  It tells CF how to build and deploy, and since I changed my servlet WAR file name, that had to go into the YML file.  After that I followed the instructions on Bluemix on how to use CF to upload.  A few minutes later I have a nice little servlet running on Bluemix.  I'm happy.



No comments:

Post a Comment