Android | UNEXPECTED TOP-LEVEL EXCEPTION:java.nio.BufferOverflowException

While buidling android applicaiton found this issue with latest android sdk of revision 22.3 and build tool revision 19.0.0.

 Here below is the stacktrace:

[dx] java.nio.BufferOverflowException
[dx] at java.nio.Buffer.nextPutIndex(
[dx] at java.nio.HeapByteBuffer.putShort(
[dx] at$Section.writeShort(
[dx] at$Section.writeTypeList(
[dx] at$3.write(
[dx] at$3.write(
[dx] at$IdMerger.mergeUnsorted(
[dx] at
[dx] at
[dx] at
[dx] at
[dx] at
[dx] at
[dx] at
[dx] at

Deleting android sdk build tool 19.0.0 is solution for this for now.
It sounds illogical but this solution will work.
Here below are the link for android google group where this is submitted as defect.
Stackoverflow question link for the same is as below:

 Your Suggestions Always Welcome.

How To Get Default Location For Code Signing Keys BlackBerry10

By default, code signing keys for blackberry10 are stored in a default location in your system. The default locations of code signing keys vary based on operating system on your computer.

Below is detail about the default location as per different operating system

Windows XP : %HOMEPATH%\Local Settings\Application Data\Research In Motion

Windows Vista and Windows 7 : %HOMEPATH%\AppData\Local\Research In Motion

Mac OS : ~/Library/Research In Motion

HOMEPATH for different operating system is as below:

Windows xp : C:\Documents and Settings\user

Windows Vista and Windows 7 : C:\Users\user

Here below is the java program to get default location of code signing keys

* Driver class
* @author Sanjay Jain

public class Driver {
public static void main(String[] args) {
try {
String rimDir = getDefaultRIMDirLocation();
System.out.println("Research In Motion Default Directory is:");
} catch (Exception e) {

private static String getDefaultRIMDirLocation() {
String osName = System.getProperty(Constants.OS_NAME);
String fileSeparator = System.getProperty(Constants.FILE_SEPARATOR);
String osVersion = System.getProperty(Constants.OS_VERSION);
String userHome = System.getProperty(Constants.USER_HOME);
String rimDirectory = Constants.RESEARCH_IN_MOTION;
String dirName = "";
// Check for mac
if (osName.contains(Constants.MAC)) {
dirName = userHome + fileSeparator + Constants.LIBRARY + fileSeparator
+ rimDirectory;
} // Check for windows except windows xp
else if (osName.contains(Constants.WINDOWS_VISTA)
|| osName.contains(Constants.VISTA)
|| osName.contains(Constants.WINDOWS_7)
|| osName.contains(Constants.WINDOWS_8)
|| osVersion.equals(Constants._6_2)) {
dirName = userHome + fileSeparator + Constants.APP_DATA + fileSeparator
+ Constants.LOCAL + fileSeparator + rimDirectory;
// For windows xp
else {
dirName = userHome + fileSeparator + Constants.LOCAL_SETTINGS
+ fileSeparator + Constants.APPLICATION_DATA + fileSeparator + rimDirectory;

if (dirName.length() == 0) {
dirName = userHome + fileSeparator + rimDirectory;
return dirName;

* Constants class for holding all constants
* @author Sanjay Jain
public class Constants {
static final String APPLICATION_DATA = "Application Data";
static final String LOCAL_SETTINGS = "Local Settings";
static final String APP_DATA = "AppData";
static final String _6_2 = "6.2";
static final String WINDOWS_8 = "Windows 8";
static final String VISTA = "Vista";
static final String WINDOWS_7 = "Windows 7";
static final String WINDOWS_VISTA = "Windows Vista";
static final String LIBRARY = "Library";
static final String MAC = "Mac";
static final String RESEARCH_IN_MOTION = "Research In Motion";
static final String USER_HOME = "user.home";
static final String OS_VERSION = "os.version";
static final String FILE_SEPARATOR = "file.separator";
static final String OS_NAME = "";
static final String LOCAL = "Local";

For windows 7  and windows vista output will be as below:

Research In Motion Default Directory is:

C:\Users\user\AppData\Local\Research In Motion

For windows xp output will be as below

Research In Motion Default Directory is:

C:\Documents and Settings\user\Local Settings\Application Data\Research In Motion

For Mac OS output will be as below:

Research In Motion Default Directory is:

/Users/user/Library/Research In Motion

Your Suggestions Are Always Welcomed.

Ant | How To Create Executable Jar ?

In this article I am going to describe about how to create executable jar file using ant file.

For this I am using a java project with an ant file.

In my previous post I have detailed how to create ant hello world ant project.

I will use the same project here as well.

To create an executable jar file one need to edit projectBuilder.xml file.

So new projectBuilder.xml will looks like as below:

Now run this ant file right click and run as Ant build.

Here I added a manifest tag with Main-class in jar tag.

This will set Main-Class in MANIFEST.MF

One can see the Manidest.MF by double click on HelloWorld.jar–>META-INF–>Manifest.MF As below:

Manifest-Version: 1.0

Ant-Version: Apache Ant 1.8.3

Created-By: 1.6.0_18-b07 (Sun Microsystems Inc.)

Main-Class: Main

One can also execute HelloWorld.jar on the command line as below.


Ant | Hello World Ant Project

Apache Ant is an open source, cross-platform based build tool that is used to describe a build  process and its dependencies and implemented in XML scripts using Java classes that ensures its extensible to any development environment (based on Java) and its  integrity with other build tools.

This article is about how to start with ant tool. In this article I am going to create a Java Project and will create a jar file  of  java project using ant file.

In my previous post I have written about Eclipse | Hello World Java Project. I am  going to use same project and here also.

So my project structure will be as below:







Now to introduce ant file create a xml file using File–> New wizard and  name it projectBuilder.xml and place below code in xml file.

Now right click on projectbuilder.xml select run as ant file. As the execution stops refresh the ant project.
A jar file named HelloWorld.jar will be in root project folder.

Eclipse | Hello World Java Project

This article is abut how to start with eclipse hello world java project.

Prerequisite: Java must be installed.

In eclipse click on File -> New Project -> Java Project (as below)


It will open new java project wizard. (as below)

Enter a valid a project name in project name text box. Click next (or one can directly click on finish also)


Click on finish on next wizard page. (as below)


Now create a new java class in src package. 


On click of class will open a page for new class entry. Enter valid class name in name text box.

Also check main method check box as below. It will create a main method in class itself.


Now a add sys out statement in main method. (as below)

public class Main {
public static void main(String[] args) {
System.out.println("Hello World !!!");

Noe one can run this as java application. (as below)


It will first compile and then run TestProject application.

On console it will print result. ‘Hello World !!!’

How To Open New Tab For HTML Hyperlink ?

HTML Hyperlink

In HTML, hyperlink can be used by using <a> tag. Hyperlink is a group of word which can be clicked and get executed by opening clicked link.

Syntax of HTML hyperlink is as below: 

Visit coffeewithcode

Here ‘Visit coffeewithcode’ text can be clicked together and for this clickable text destination is which is described in href attribute of <a> tag. So on click of Visit coffeewithcode it will open http://www in same tab / browser.

In case if once required to open hyperlink in new tab / browser window then also it is possible.

For this one need to add new attribute target and value for this attribute is “_blank”.

So new syntax will be as below:

Visit coffeewithcode

Now on click on ‘Visit coffeewithcode’ will open http://www in new tab / windows.






How to install Oracle libraries for PHP5 on Ubuntu Server

An easy way to Connect Apache server (PHP) with Oracle database.

Execute following command in terminal to complete installation of oracle OCI8 extension in php.ini.

1) Get Oracle repository from this link. unstable main non-free

2) Make sure to add the proper GPG key for the repository.

      sudo wget -O- | sudo apt-key add –

3) Get all the packages for PHP5, Oracle, and Apache2 server.

       sudo apt-get update

       sudo apt-get install build-essential

       sudo apt-get install php5-dev

       sudo apt-get install php5

       sudo apt-get install php-pear

       sudo apt-get install oracle-xe-client

       sudo apt-get install apache2

       sudo apt-get install libapache2-mod-php5

4) Install Oracle OCI8 library.

       pecl install oci8

5) This will ask for your home directory. At the time of installing the Oracle client was installed in following path :


6) When the installation is complete you will need to add the extension information to both instance of php.ini.

     echo “” >> /etc/php5/cli/php.ini

     echo “” >> /etc/php5/apache2/php.ini

7) Restart Apache2 server.

    /etc/init.d/apache2 restart

Now make a simple test to find oracle connectivity with php.

Make test.php and paste following  code.

Php code for twitter interaction

Let’s take a look how php code interacts with twitter.

1.) How to get number of  twitter followers.

fnction get_followers($twitter_id){
if (preg_match('/followers_count>(.*)

Now call this function with this code

$followers = get_followers(‘vimalm4u’);
echo “You have”.$followers.”followers!”;

2.) Get number of retweets for a specific page.

       Function will get the number of  retweets of the url passed as a parameter

function rtweetCount($url) {
$content = file_get_contents("".$url);
$element = new SimpleXmlElement($content);
$retweets = $element->story->url_count;
return $retweets;
} else {
return 0;

echo rtweetCount('');

3) Shorten urls for Twitter

      As we know, we can’t tweets messages which are longer than 140 characters. To avoid this problem, you have to use an url shortener.


function getTinyUrl($url) {
return file_get_contents("".$url);

How To Call A Java Script From Java Code?

This post is to describe how to call a java script from java code.

Below is  java file.In which there is a main method.In this main method a script engine instance is taken.This script engine is already with jdk.For this one need not to add any other jar file.


import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

public class Driver {

* @param args
* @throws FileNotFoundException
public static void main(String[] args) throws FileNotFoundException {
try {
* To call a anonymous function from java script file
ScriptEngine engine = new ScriptEngineManager()
FileReader fr = new FileReader("src/js/MySpec.js");

} catch (ScriptException scrEx) {

Below is the java script file with an anonymous fuction.This function is to print on the console.

// java script anonumous function
(function() {
print('Hello world');

Below is the folder structure of the project.

Folder Structure

Folder Structure

Your Suggestions Are Always Welcomed.


Hibernate plugin in eclipse

In previous post I describe about how to hibernate plugin the eclipse.In this post I am detailing about how that plugin will be helpful in development.

While creating any new hibernate related file this plugin will help you by configuring the parameter which are necessary to create that file.

Below are the suggestion by hibernate plugin in the new wizards.

Hibernate plugin in eclipse

Hibernate plugin in eclipse

On click of any of four link it will start a new wizard.New wizard will ask for the required input parameter to build respective file.By using this wizard one need not to create specific file manually and do entries.

While working with hibernate mapping file hibernate plugin also help with suggestions of bean properties.

There may many other features of hibernate plugin which are helpful at the time of development.As I came across I will share them on this blog.

Above are the benefits at the time of the development.Hibernate plugins also provide a complete hibernate tutorial inside the eclipse with examples.

To see the hibernate tutorial inside the eclipse go to

  • Help
  • Help Contents

It will open a new windows.This contains the guide to develop hibernate application with examples.

Here below is the screenshot of newly opened window:

Hibernate plugin in eclipse

Hibernate plugin in eclipse

Your Suggestions Are Always Welcomed.