Contents


Unit 23: Java in the cloud

Deploy Java applications to IBM Cloud

Comments

Before you begin

This unit is part of the "Intro to Java programming" learning path. Although the concepts discussed in the individual units are standalone in nature, the hands-on component builds as you progress through the units, and I recommend that you review the prerequisites, setup, and unit details before proceeding.

Unit objectives

  • Download, install, and set up the WebSphere® Liberty application server
  • Install the Eclipse Tools for IBM Cloud
  • Test the sample application locally from Eclipse
  • Push the application to IBM Cloud from Eclipse
  • Modify the app, retest it locally, and redeploy it to the cloud

Cloud development with Java

So far, you've only run the human resources (HR) application code on your own computer, from within Eclipse. But browser-based business applications are now common — and it's becoming increasingly convenient to deploy such apps in the cloud. No doubt you're curious where Java programming fits into the cloud computing picture. This unit aims to satisfy that curiosity by showing how to deploy a web version of the HR app in the cloud using IBM Cloud and WebSphere Liberty — all without needing to leave the comfort of Eclipse.

Java web programming rightly deserves its own specialized treatment, and you'll get only a small taste here. To make it easy for you to follow along hands-on, I've made the source code for a web version of HR app available on GitHub. (If you explore the project's src/com/makotojava/intro/ folder, you'll find Person, Employee, Manager, and all of the other Java classes that you've been working with.)

The steps that you'll perform follow a typical development cycle: Develop and test an app locally, push it to the cloud, modify and retest the app locally as needed, and redeploy it to the cloud.

Set up the tools, test the app locally, and push it to IBM Cloud

If you don't already have an IBM Cloud account, register now.

Next, pull the code from my GitHub project and import it into your Eclipse workspace. Then follow along with this video demo:

Good work! You've deployed your application to the cloud.

Modify the application and test it locally

Of course, as software developers, we know that deployed applications must be maintained through bug fixes and enhancements. You'll simulate that process now by making a small change to the HR app and then testing the change locally in your Liberty server before redeploying to the cloud.

In your Eclipse project, uncomment the following lines of code in the createEmployees() method in HumanResourcesApplication.java:

//
e = new Employee("Christine Johnson", 33, 160, 60, "BROWN", Gender.FEMALE, "424-45-9999", "0005", BigDecimal.valueOf(190000.0));
ret.add(e);

Now test the change locally: Start your local Liberty server, bring up your browser, and verify that a new row that includes Christine Johnson is displayed in the app:

Screenshot of modified human resources application
Screenshot of modified human resources application

Push your modifications to the cloud

Now that you've tested the change locally, it's time to push the modified app to the cloud, just as you would for a real-world application.

Stop your local Liberty server. Then follow the same deployment steps as before — except this time, all you need to do is specify the IBM Cloud server to deploy to (select the one you set up earlier, if it isn't automatically selected). Then click OK.

You might notice quite a bit more output this time as IBM Cloud updates your application. After the app is deployed, you'll see a message similar to this one (it might differ slightly):

[AUDIT   ] CWWKF0011I: The server defaultServer is ready to run a smarter planet.
[INFO    ] CWWKF0008I: Feature update completed in 23.875 seconds.
[Application Running Check] - Application appears to be running - javalearningpath.

Now go to your browser and access the application at the Deployed URL and verify that your change is in the cloud version.

IBM Cloud is a powerful platform, and I've only scratched the surface of its capabilities in this unit. I encourage you to check out the resources under For further exploration to learn more about IBM Cloud.

Fini

Kudos! You've completed the "Intro to Java programming" learning path.

For further exploration

Get started with IBM Cloud

IBM Cloud container tutorials

Tutorials on IBM Cloud services

IBM Code

Previous: Java serializationNext: Learning path summary


Downloadable resources


Comments

Sign in or register to add and subscribe to comments.

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Java development
ArticleID=1036650
ArticleTitle=Unit 23: Java in the cloud
publish-date=07122018