Monday, April 15, 2013

MySql series: Lesson 1

Starting and connecting to the MySQL server on Windows 7

Objective: If you have a Windows 7 64 bit machine and MySQL is not installed as a service, how would you start MySQL from the command line?
Step 1:
Open up a command line prompt in Windows and type in:
 mysqld –console
If all went well, you should see something like below:

Step 2: Connect to the MySQl server using the command line client ‘mysql’
Open up another command line window and invoke the mysql command line client ‘mysql’. You are now all set to interact with the MySQL database. In the next lesson I will show you how to do more useful stuff with MySQL.


Wednesday, April 3, 2013

Android Lesson 3: Run your app on the emulator


The objective of this lesson is to teach you how to run your app in the emulator. Whatever app you develop, be it in Eclipse or on the command-line, you need to run it in the emulator. For context, please refer to my previous lesson in the Android series.


Step #1 Make sure you are using the Java Perspective
  To create an Android Virtual Device, you need to make sure your Eclipse Workspace is using the Java perspective.

Step # 2 Launch the Android Virtual Device Manager
Launching the Android Virtual Device Manager is the first step to creating an AVD
In your Eclipse, select the item highlighted in the screenshot below.

The Android Virtual Device Manager dialog opens. Click on New..
Step # 3 Leave defaults in most fields except AVD Name and Memory Options. Eclipse recommends you use 768 instead of the default number.
In the Create new Android Virtual Device dialog window, use the following configuration options as shown below:

Click OK. You now have created a new AVD that is listed under the “list of of existing Android Virtual Devices….”
Step # 4 Start your Android Virtual Device.
Select the new AVD and watch the Start Button get enabled. Click on the Start button. You will see a new dialog window as shown below.

Clicking on the Launch Button boots up the Emulator. If all went well, the “Starting Android Emulator window” displays a progress bar.


Patience pays. Here is the Emulator itself:


Step # 5 Start the app in the Emulator
You may recall that we created a simple Android App called “SimpleProject” in the Eclipse workspace not so long ago. Just as before, select SimpleProject, right-click on it, select Run As and “Android Application”. You will notice activity in the Console screen on your right hand side at the bottom of your screen.


Look at the items highlighted. Don’t worry about the bounded red area for now. If you look at your Emulator now, you see Hello World in it. That’s it. You have just created and deployed your very simple Android App in the Emulator.

Step #  6 You have just seen how to build and deploy a simple Android app. Before I go on to the next lesson, you will find it useful to inspect the SimpleProject folder in Eclipse and understand what artifacts the build process generated for you. In Step # 5, you will notice that the Console Window displayed a line telling you that it installed “SimpleProject.apk”.  To find out where this file might be located, navigate to the location of SimpleProject in your filesystem.
As it turns out, the apk file is under SimpleProject\bin directory.


Concluding Remarks: In this lesson you have seen how to launch a simple Android App in the Emulator. In the next lesson, we will learn how to build a simple User Interface for our Hello Jeffrey Android App.

Sunday, March 24, 2013

Android Series: Lesson-2

How to create a simple Android project with a default set of “Hello World” source files.

The objective of this lesson is to create a simple Android project with a default set of “Hello World” source files that will allow you to immediately run a very simple app.


# 1 For the newbie developer, please refer to the contents of Android Series: Lesson-1
For those not needing such material, feel free to skip to Step # 1


Step #1: Create a new Android Project in Eclipse and set it up with default files.
On the toolbar referenced below,
Click File –> New –> Other –> Select Android Application Project –> Next

On clicking the Next Button as in the previous screen, navigate to the next dialog and enter Application Name, Project Name and Package Name. The rest are defaults and are best left alone at this point.


Clicking Next as in the previous screen takes you the next dialog as shown below. I would leave the defaults alone. Note: We are about to create a project called SimpleProject in our Eclipse Workspace ‘workspace’.


The next window is the New Android Application – Configure Launcher Icon
If you so wish, choose a clipart from the file system, made Background Color and Foreground Color Selections and click Next


Clicking Next takes us to the Create Activity window. Choose Blank Activity, leave all the details for the activity in their default state and click Finish. Click Next.

Move on to the Blank Activity screen where you leave the defaults alone and click Next
Project SimpleProject is created with default artifacts and is displayed in the Project Explorer Pane as shown below: The most important default files that are relevant are: under package com.att.simpleproject, activity_main.xml under res/layout, and strings.xml under res/layout.

In fact, Eclipse automatically loads activity_main.xml (also known as the layout file) for the first time. 

Displayed in its Graphical Layout view, the layout displays a simple view that has a very simple string “Hello World”.  You can easily view the source for the layout file by clicking on the activity_main.xml tab.




Step #3: Inspect the default files and make some simple changes to them.
In the activity_main.xml file shown above, note the line that says android:text=”hello_world” />

Change hello_world to simple_message and do a Ctrl+S to save it.
Next open up strings.xml and note the line that says  “<string name="hello_world">Hello World</string>
Now you can change that Hello World to anything you want. Just for fun, I will change this to Hello Jeffrey

Save your changes.You now have -

This concludes this lesson. In the next lesson, I will show you how to run the SimpleProject Android app. I do this in an emulator. Later we will see how to run this in an actual device as well. For now lets get our feet with the Android emulator.

Saturday, March 23, 2013

Android Series :- Lesson-1: A developer’s guide to setting up the Android SDK on a Windows 64 bit machine


  What are the minimum system requirements?
         64-bit Windows machine with at least 2 GB of memory
.Note the items circled in red. These are the minimum system requirements.
.  Note: JDK 6/7 – if you do not have Java installed, please refer to my tutorial here

Step # 1

Download the Android Developer Tools (ADT) Bundle into a folder of your choice. I call this folder called Android. See screenshot below for context.

At the time of this writing, the latest Android SDK is available here:
The ADT bundle ( has everything you need to start developing apps.

Step # 3

Set up the downloaded ADT bundle.

Unzip by doing a right-click on it and choosing the “Extract Here” option. The unzipped folder adt-bundle-windows-x86_64-20130219 has the file folders eclipse, sdk and the Application SDK Manager.

That’s it. We have successfully installed the Eclipse IDE (pre-loaded with the ADT Plugin), the Android Software Developer Kit (or Android SDK For short) and the SDK Manager.

We have just covered prerequisite steps to start writing code for our Android apps in the Eclipse IDE.
Step # 4
Launch Eclipse by double-clicking on the eclipse application icon.
This will launch the Workspace Launcher. A window similar to the below will be presented to you. Pick a location for a workspace and an appropriate workspace (for e.g., C:\Android\android-workspace) by using the Browse button or by simply typing in the aforementioned path into the Workspace: form field or just accept the defaults and click OK.

Step  # 5:
Eclipse complains it cannot find the SDK folder. What should you do?
The way out is to click on “Open Preferences”. This launches a new Window called Preferences that looks like the one below. Then click on the  Browse button and select the folder on your machine where the “sdk” resides. What you see below is the actual path to the Android SDK on my machine. Click Apply and click OK. This closes the Preferences

Exit Eclipse and restart it to see the effect of your changes. If all is well, you will not get that annoying window that you got the first time you launched Eclipse. Now you are all set to start writing code for your very first Android app.
What next?
In the upcoming lesson – Lesson-2 - of my Android series I will cover the basics of Android app design culminating with the development of a simple app.

Sunday, January 27, 2013

Tutorial - Getting started with Java PathFinder



Two years ago, I stumbled into the Java PathFinder (JPF) project on the internet. I was intrigued by it. The literature available at the JPF Official Site ‘ “was kind of daunting, but going through this documentation saved me a lot of time. The first time I tried to set it up, I failed. JPF languished at the back of my mind for a long time. Early this year, I decided to try again. I decided that a good way to learn and retain JPF in my head was to make a record of what I did, regardless of whether I failed or not. That is why this tutorial was born.

The objective of this tutorial is to help me or anyone else build, configure and test JPF

To make the most of it, the following prerequisites are a must:

1) Java 6 or greater

2) Eclipse 3.5 or greater

3) Mercurial 2.0 or greater

4) Windows XP/Vista/7

Note: When I started writing this tutorial, I simply worked my way through and discovered what I needed. Feel free to skip those steps that you find unnecessary.

All the steps listed below helped me install, configure and run JPF on a Windows machine. The next section answers what JPF is to give us an idea.


What is JPF?
The first glimpse into JPF is afforded us by the official JPF site listed at the very beginning. Combine this with information thrown up by the search engine, JPF is a NASA-developed software model checker specifically meant for analyzing software programs.

With this information, let us get started on setting up JPF. The best place to do so is at the JPF Wiki, which is the primary source for JPF documentation.

Step # 1

1) Navigate to:

2)  We will download the source for jpf-core from the Mercurial Repository directly into our Eclipse project space as a Java project and build JPF. This is the repository we will use:- 

3) The Mercurial Eclipse plugin needs to be set up. Installation instructions are here.


Step # 2

Set up the Mercurial Eclipse plugin:

The below screenshots show you how to use the Mercurial Eclipse plugin to download (the Mercurial term is “clone” and the equivalent SVN term is “checkout”) jpf-core.

Bring up your Eclipse IDE (I tend to use the Scala IDE based on Eclipse 4.2).

Start by clicking on Help -> Install new Software. The following screenshots help you through the rest of the process.

Work with the the following update site:

Step # 3



Follow the screenshot and you should be good. Continue with installation by clicking Next. A few clicks later, Eclipse prompts us to restart for the installation to take effect. On restarting Eclipse, I run into a problem:


It appears I have an older version of Mercurial that needs to be replaced by a Mercurial version of 2.0.0 or above.

Step # 4

Download and set up the latest Mercurial.

Navigate to: and download Mercurial-2.5

Once the Mercurial installer is done, modify your PATH environment variable in Windows Control Panel to point to the Mercurial bin directory. Restart the system for the changes to take effect and type hg on the command to make sure Mercurial set up went just fine.

Step # 5

Once my system was back up, I started Eclipse and clicked on Preferences to bring up the Preferences Window.

In this Window, the left panel has Team -> Mercurial; I navigated to the “GnuPg Executable” form field on the right-hand side pane, clicked on Browse and selected the location of hg.exe. I left the defaults alone, clicked Apply and then Ok to exit the Preferences Window.


Mercurial Eclipse installation is now complete.In the next step we will clone the repository hosted at:

Step # 6

In the Eclipse menu, I did: File –> Import


A window similar to what you see below will present itself. Here you will select “Clone Existing Mercurial Repository” under Mercurial.

Click Next to summon up the “Mercurial clone repository wizard”. This is shown in Step #9 where you will fill in necessary information.

Step # 7

Mercurial clone repository wizard:

Fill in URL and Username values below to start the ‘checkout’ process.  

Click Next to proceed to the “Select working directory revision” wizard


Step # 8

The Select working directory revision wizard


Clicking Next (above) takes me to the next window shown below:


Click Finish. The Import Projects wizard will download the jpf-core into our Eclipse workspace, if everything went well.

Step # 9

Checking to see if jpf-core is downloaded (cloned) into our local repository:

Inspect your Package Explorer for evidence of jpf-core


Step # 10

Build the jpf-core project:

Right click on build.xml -> Run As -> Ant Build (Alt+Shift+X)



Step # 11

Ant will compile all the source files in the jpf-core project and generate a build folder (jpf-core/build) with the artifacts of the build, the most important being the jpf.jar file. If you can’t see this under package explorer drill down to your workspace in File Explorer and verify the contents of the build folder. You should also find a folder called examples containing class files compiled from src/examples.

Step # 12

Configuring JPF:

Navigate to:

Update: Based on inputs from Peter Mehlitz of Nasa Ames Research Center (thank you, Peter), I updated the information on to include key information that I had naively omitted. So, in Peter’s own words “site,properties is a file that is telling JPF during startup where to look for installed JPF extension projects (such as the symbolic execution mode), which follow pretty much the same install procedure as jpf-core. JPF is not a monolithic tool but rather a framework to create your own tools by means of runtime configured extensions” The file can then add classpaths to these extension projects (including setting up the path to jpf-core itself), sparing us users and (developers) the pain of typing in classpaths ourselves.

Create this file in your favorite text editor and save it under the .jpf folder in your user directory. On my computer it is under: C:\Documents and Settings\ig911y\.jpf


To complete configuration, one last step is needed - installing the JPF Eclipse plugin. This plugin will enable us to run these examples directly from under Eclipse, thus verifying that we have a basic working JPF installation.

For more details, let’s move over to Step # 15.

Step # 13

Continue configuring JPF by installing the JPF Eclipse plugin:

The Eclipse JPF Plugin allows you to invoke JPF from Eclipse directly. Install it using Help -> Install New Software and walk through the process. It should be a breeze.

At this point, the basic setup is complete. We are now ready to test our JPF installation by attempting to run the most basic example ( under the src/examples folder.

In the next step I show how to run the HelloWorld example.

Step # 14

Launch JPF for the first time, test HelloWorld and verify JPF installation:

Locate HelloWorld.jpf under src/examples and right-click on it. The context menu should have the “Verify” item in it. Invoking the “Verify” menu item launches JPF and tests the HelloWorld program. If you see “Verify” things are well, up until this point. For relevant context, please refer to the screenshot below.


What happens next is important. If you saw the following output, you are good to go.


The basic elements of JPF installation are in place. Having come this far is a small but essential step in learning JPF.


What we have here is a simple, working installation of JPF that allowed us to run JPF from Eclipse. Where do I go from here? In Part-II of the JPF series I will attempt to analyze the outcome of testing HelloWorld.

Stay tuned! Thanks for reading my article.