Friday, 18 September 2015

Using WAS Liberty with added IBM Java

Alasdair Nottingham gave a nice overview of the options we have for installing WAS Liberty.  There are a few options, but I think he did a good job of explaining their existence.  One thing I wondered about was the broader use of the IBM Java once you got hold of it.  For example, how do I know the Java is being used?  Can I package it back up with my server?  So, I did a bit of experimenting.


You can download the WAS Liberty Zip that includes IBM Java from the WebSphere Liberty Repository here.  This zip, as the name suggests, includes all the features required to run Java EE 7 Web Profile applications.  At the time of writing, the server is licensed for development use, with limited production use (just in case it changes ;) ). 


To get started with Liberty and IBM Java, you just unzip the package.  E.g.


This will create a directory called wlp and under that directory you should see the following directories and files:

If you're familiar with other Liberty packages, the new directory to note is the one called java.  That's it, that's the IBM Java. 

Creating a Server

The install doesn't contain a server configuration so you next need to create one.  In a command prompt (yes, I use Windows :S) in the wlp directory, type:

bin\server create myServer

This creates a server called myServer with the default configuration to start the webProfile-7.0 feature (see the featureManager entry in wlp\usr\servers\myServer\server.xml).

From here you can install more features using bin\installUtility, develop and deploy applications and so on. 

Starting the Server

You can start the server using the start or run commands.  E.g.

bin\server start myServer

Check to see which Java is being used (e.g. using Task Manager or ps).  I got a bit of a surprise as mine wasn't using the included IBM Java.  This was because I already had Java on my system and so it picked that one up based on my JAVA_HOME setting.  You need to unset that to get it to pick up the included IBM Java (e.g. set JAVA_HOME= ).

Packaging it up

Let's say you've finished developing your super awesome application or you've created a custom server install that you want to package up, including the IBM Java.  This is useful if for example to create a distribution to put on another system whilst not having to rely on the right level of Java being provided on that system.  Before you do this, though, you might want to change the licensing for production use.  If you've purchased a WAS Edition, you can apply the license using a license.jar that you download for Passport Advantage.  OK, back to packing up the server.  This is simple, using the server package command.

To just package up the server install and not your server.xml and application, you do the following:

bin\server package --include=wlp

This creates a file with all the runtime, include IBM Java under the wlp\usr\servers directory.

To package up the server install along with your server configuration and application, you do the following:

bin\server package myServer --include=all

This creates a with all the runtime, IBM Java, server configuration and application(s) under the wlp\usr\servers\myServer directory.

That's it!  Pretty simple really.  The only real gotcha from my perspective was the JAVA_HOME.  I hope you find this useful.  Please comment if there's something I could explain better or you spot a mistake.  Thanks.


Unknown said...

Simply Awesome Explanation!!!! very use full Sir.

Jose Luis Chilet Rojas said...

From Peru, Interesting article, I'll try this version of the application server