« Back to home

Bluemix J2EE basics with Eclipse and WAS Liberty Profile

IBM Bluemix is a cloud platform build around Cloud Foundry, OpenStack, and other popular open source projects. As well as using it to deploy Go, nodeJS and PHP applications, you can use it to develop J2EE applications. To do so, you can use WebSphere Liberty, a clean ground-up implementation of J2EE in a single 60MB download. Don’t confuse it with the old WebSphere Application Server — this new beast can start up in seconds and run in 512MB of RAM.

I decided to see how easy it was to get up and running. Here are my notes:

Step 1: If you don’t already have it set up, download Eclipse and get it running. I used Eclipse IDE for Java EE Developers.

Step 2: If you don’t have them installed already, you’ll need to download and install the Bluemix CLI and Cloud Foundry CLI tools.

Step 3: Download the runtime for WebSphere Liberty Profile with Java EE 7 Web Profile and install it by unpacking the archive somewhere. I unpacked it to /usr/local/wlp, owned by my regular ID (because the directories need to be writeable).

Step 4: As per the getting started with WAS Liberty page, drag-drop the Install link onto Eclipse’s toolbar, and we’re off to see the wizards. You should be led through the process of setting up Bluemix as a Cloud server deployment in Eclipse.

Step 5: Log in to Bluemix via the web console, and create your app using the Liberty for Java runtime.

Step 6: Bluemix will offer you a starter code bundle. Download it and unzip it into Eclipse’s workspace directory.

Step 7: Use File > Import > Existing Projects Into Workspace to import the project into Eclipse. It’ll complain about missing info, but you can ignore that.

Step 8: Right click the project in the Project Explorer, and choose Run As > Run On Server. At this point Eclipse gives you the choice to choose an existing server, or manually define a new one.

If you choose Choose an existing server, you should see IBM Bluemix listed. Chances are the state is shown as Started, because Bluemix started your new application when you created it.

You might hit a Java version problem. First time through, I got an error saying “Project facet Java version 1.7 is not supported”. The solution was to remove the project from Eclipse, restart Eclipse, make sure Java 1.8 was my default runtime, and then re-import the project. There’s probably a way to do it by editing preferences, but after spending a while wandering around in a maze of Eclipse configuration settings I was unable to find it. Short answer: make sure you’re running the same JRE version as Bluemix supports, which at the time of writing is IBM JRE 1.8.

At this point, you can try editing the Java source code for SimpleServlet.java, ask Eclipse to run it on a server, choose Bluemix, and then watch as the Eclipse console builds and uploads the application and redeploys the changes.

Once you’ve done that a couple of times, you’ll notice that it takes a minute or so. To save your sanity, select Run On Server again and choose Manually define a new server. Click the Configure runtime environments link, and we’re off to see the wizard again. In the dialog that appears, pick “WebSphere Application Server Liberty”, and click the Next button.


In the next dialog, tell Eclipse where you unpacked the WAS Liberty runtime earlier.


Finish and OK your way back to the Run On Server dialog. You should now be able to select WebSphere Application Server Liberty as a server type, and choose the runtime environment you just defined.


Clicking Finish should make Eclipse fire up WAS Liberty, deploy your application to it, and launch an embedded web browser to demonstrate that it works.

Finally, you might want to set up a Maven “Run As” configuration for the project, with a list of Goals consisting of the word package. That will get Maven to build and package the entire application into a .war file in the target directory of the project directory. You should be able to use that WAR file for deployment.

All working? git init and put it all in a repository before you break anything.