The demo is provided only as a technology preview of COBOL code operating on an Android emulator or real device. Micro Focus cannot commit to providing support for the Android platform in the future and there are no bug fixes at the moment. The demo was created exclusively for the Micro Focus Community to use and provide feedback to help determine whether Micro Focus should support the Android platform in the future. Limitations include:
Please review the add pack readme for more information.
Recently we’ve demonstrated Visual COBOL running on Android
devices in several forums, including the R3 launch in January 2011. It’s one of
the things that seem to fire the imagination of customers and staff alike, and
we’ve had lots of requests for more information.
We’ve decided to make the sources for this demo available on
the Micro Focus Community web site, and this is a short article to explain how
you can get the demo up and running.
The COBOL Android demo is a proof of concept which shows
COBOL code running directly on an Android emulator (part of the Android SDK) or
on an actual Android device. The application does an interest calculation to
provide a quote for a loan. The quote can optionally be sent back to a web page
using URL query syntax – but the default web server is an Azure instance which
is no longer running. You can change the URL to a web server you supply if you
want to see this part of the application run.
It consists of three Eclipse projects:
Android itself does not use a regular JVM like the ones
supplied by Oracle or IBM, but a special JVM optimized for small memory
footprints and limited resources, called Dalvik. The actual format of .class
files for Dalvik is completely different to regular JVM. When you upload a Java
application to Dalvik using the Android SDK, the regular Java byte code is
converted to Dalvik format and packaged into an .apk file before upload.
Because the Android tools work with regular JVM files, we
are able to upload COBOL to Dalvik in the same way as Java. But Dalvik is not
the same as a regular JVM and currently there are some things in COBOL programs
that currently do not work when translated to Dalvik; you will see runtime
errors in the Android Eclipse LogCat window .
In addition, debugging COBOL in Dalvik does not work as well
as it does for regular JVM. You can see the variables changing value in the
variables window, but breakpoints are ignored and the execution point does not
reposition correctly as you step through. Because of these sorts of issues, you
should regard the Android support being demonstrated here as a Technology
Preview to show you what is possible. It is not currently a supported product.
To run the demo you need to install the following:
Once you have all these installed, you need to install at
least one Android platform in your SDK – the one you need to run the demo is
for API Level 8. To do this, open the Android SDK Manager, and download the
Android 2.2 (API 8) SDK Platform. The
SDK manager shows the SDK Platform for all the Android APIs released so far,
but by default the only platform actually downloaded will be the latest one.
Select Android 2.2 (API 8) SDK Platform and Samples, and click the Install Packages button.
You also need to create a new Android emulator (or Android
Virtual Device). If you haven’t used the Android SDK before, Google’s Hello
World tutorial will take you through these steps.
Your emulator should target API level 8 or later to work
with the COBOL Android Demo – level 8 is the API supported by the majority of
Android devices in use at the time of writing. Tablet devices running Honeycomb
are at API level 11. Android API levels are always backwards compatible – level
8 is the minimum API required to run this demo so higher levels should also
work, but we can’t guarantee this as we haven’t tried them all.
Now you can import the demo projects into Eclipse.
You should end up with four sub directories
under the CobolAndroidDemo
You now have three projects in your workspace, InterestCalculator, InterestCalculatorClient and QuoteCommunicator. If your workspace is
set to build automatically (the Eclipse default) the projects will be built
within a few seconds. There should be no warnings or errors in the Problems
window if everything is set up correctly. The likeliest cause of problems is a
failure to set up the classpath variable correctly – the imported projects need
to be able to find a special version of the COBOL runtime to work with Android,
and this is in the RTE directory. The classpath variable should point to the
root directory of the demo and all the projects extend this variable into the
At this point you should have the projects all imported and
built correctly, so you can run it on the emulator you set up in Before you start. Right-click on the InterestCalculatorClient project and
click Run as, Android Application. This starts up the Android emulator and uploads
the InterestCalculatorClient.apk package file. It can take up to 30 seconds for
the emulator to start and for the package to be uploaded – if you display the
Android console (available from the Display Selected Console icon on the
right-hand side of the Eclipse console window) messages will show you the
Once the application has started running it looks like this:
You can enter different values in the fields, and click Illustration to see the result.
To change the settings for the application, click the
emulator’s Menu button and then click the Settings button that appears at the
bottom of the application. The application now looks like this:
You can change the URL for saving quotes from the supplied
default, and also select the name of a different loan advisor from the drop
down list. Click Apply to save your changes and return to the application
screen. These changes persist until you delete the application from the
emulator or device it is installed on.
When you click Illustration, the Save Quote button is
enabled, and clicking this takes you through to the Save Quote screen:
When you click Send to cloud, the application makes an HTTP
request to the web page specified in the settings screen, appending a query
string with all the parameters for the quote, as well as the longitude and
latitude from the GPS device if one is available. This is the format of the query
You can see how this string is built up in the DataSender class in the QuoteCommunicator project.
The diagram below shows the three projects and the main
classes in the application. It does not show all the classes.
The UI is in the InterestCalculatorClient
project on the left. Both these classes are Android activities which display
the UI defined in the project’s res/layout folder. The InterestCalculator project contains the code which actually does
the calculation, inside the ProceduralCalculator
program (ProceduralCalculator is not
a class, it is procedural COBOL which could have come from a green screen
application where it would have been compiled as native code.
You can modify the supplied application using Visual COBOL,
or even write your own new COBOL code for deployment. Remember though, Visual
COBOL Android support is only a technology preview – it does not even have the
status of a beta product at the moment.
There is no access to the COBOL file handler, so you can’t
use COBOL files (you can use Android’s storage APIs to save data, and the
application uses the Settings API to store its configuration). Also, not all
COBOL statements will work correctly or at all – don’t be surprised if you get
Dalvik verifier and other runtime exceptions when you try to run code you have
changed. Please let us know about things you find that don’t work as expected,
although at the moment we are not making a formal commitment to fix them.
You can connect an Android ‘phone or tablet to your computer
via USB in order to install the demo on it. See Google’s Using Hardware
Devices for more information. On Windows computers you need to follow their
instructions on installing the USB driver – which can differ slightly from one
device to another. On the device itself, you need to enable USB Debugging.