December 30, 2011

Android NDK JNI Windows xp/7 with 32/64 bit Installation Problems with Solutions in Eclipse without C/C++ CDT Plugin

Hi all,

I spent 2 days on configuring this. I read lot of blogs and instrutction steps from various sites. I would like share my experience on installing Android NDK and Working with Eclipse.

Objective:
Using JNI Technology in Eclipse with Android NDK r6/r7 on Windows xp/7 Professional

Pre-requirements:
  1. Java SE SDK -- Java Development Kit
  2. Eclipse Helios/Indigo -- IDE to work with Java, Android, C/C++ etc.
  3. Android SDK -- Android Applications Development Kit
  4. Android ADT Plugin for Eclipse -- Download the latest Android SDK Platform Tools
  5. C/C++ Plugin for Eclipse (Optional) -- Make sure that .c, .cpp, .h files opening from Eclipse
  6. Android NDK (r6/r7) -- Native development i.e. Running c libraries in Android
  7. Cygwin 1.7.x or above -- Makefile creation, Library file creation tools, Compiling C files

Installation:
  1. Install the Java Development Kit
  2. Install the Android SDK and ADT Plugin with Eclipse
  3. [Optional] Install CDT plugin for Eclipse
  4. Download and extract the Android NDK
  5. Install Cygwin 1.7.x or above
Note: Don't extract in a folder where folder name is having spaces in between words.
Example:
"Program Files" -- Don't Use
"ProgramFiles" -- Use

Configuration:
Please make sure that you have set the environment variables like
  • JAVA_HOME -- Java Home Directory
  • NDK_HOME -- Android NDK Home Directory
  • Update Path Variable with JDK Bin folder
Creating Android Application
  • In Eclipse, Select File->New->Android Project
  • Enter the Project Name and Click on "Next" button
  • Select the "Build Target", I opted for Android 2.2, SDK 8 Version and Click on "Next" button
  • In Application Info dialog, enter the "Package Name" and Select "Finish" button
  • Now, you can see the newly created SampleNDK project in the eclipse project explorer window

Example:
  • Eclipse Workspace Folder: D:\Workspace
  • Android Application Name: SampleNDK
  • Android Application Working Folder: D:\Workspace\SampleNDK
  • Package Name: com.samplendk
  • Android Application Source Folder: D:\Workspace\SampleNDK\src

Source of AndroidNDKActivity.java
package com.samplendk;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;

public class SampleNDKActivity extends Activity {
   
    //Declare the native method
    private native String invokeNativeFunction();
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        //Call the native methods
        String hello = invokeNativeFunction();
        new AlertDialog.Builder(this).setMessage(hello).show();
    }
   
}

  • Create a folder named "jni" in the project
    • Right click on the "SampleNDK" project-> Select "New"-> Select "Folder"->Type "jni"
  • Create files "Android.mk" and "native.c" in Jni folder
    • Right click on the "jni" folder-> Select "New"-> Select "File"->Type "Android.mk"
    • Right click on the "jni" folder-> Select "New"-> Select "File"->Type "native.c"
  • After Creating those folder and files, the project explorer window look like this
  • Do some continuous steps.
    • Build, Refresh, and Clean project
      • Right Click on the "SampleNDK" project and Select the "Build Project"
      • Select "Sample NDK" project and Click "F5" button on keyboard
      • Select "Project" menu and Select "Clean" option

  • Create header file of the java file
    • In windows command prompt, change to project source directory
    • Syntax:
      • cmd>
      • cmd> cd ProjectDir/src

    • Example:
      • cmd> D:
      • D:\> cd SampleNDK/src
    • Run the Javah command to create header file
    • Syntax:
      • cmd> javah -jni .javafile_without_.java_extension // JDK 1.7
      • cmd> javah -classpath ..\bin\classes .javafile_without_.java_extension //JDK1.6
    • Example:
      • D:\SampleNDK\src> javah -jni com.samplendk.SampleNDKActivity //JDK1.7
      • D:\SampleNDK\src> javah -classpath ..\bin\classes com.samplendk.SampleNDKActivity //JDK1.6
    • Note:
      • Don't include the .java at the end of javah command

  • Copy the created java header file to jni folder
    • D:\SampleNDK\src> copy com_samplendk_SampleNDKActivity.h ..\jni

  • Go to Eclipse and Refresh the project by pressing "F5" on keyboard.
  • Open the header file from jni folder
  • Copy the function created by javah as shown below
  • Paste the code in native.c and change the code similar to this
Source of native.c
#include <string.h>
#include "com_samplendk_SampleNDKActivity.h"

jstring JNICALL Java_com_samplendk_SampleNDKActivity_invokeNativeFunction
  (JNIEnv *env, jobject obj)
{
    return (*env)->NewStringUTF(env, "Hello from native function !!");
}

Source of Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
# Here we give our module name and source file(s)
LOCAL_MODULE := SampleNDK
LOCAL_SRC_FILES := native.c

include $(BUILD_SHARED_LIBRARY)

  • Run Cygwin.bat file in the Cygwin installed directory
  • It will open the cygwin command prompt
  • Change the directory to SampleNDK project directory
    • Note: All the drives in your systems are mounted to some directory in the cygwin.
    • To see your drive mount points type mount
    • # mount
  • # cd /cygdrive/d/SampleNDK/
  • Run the ndk-build command from the android ndk directory
    • # /cygdrive/d/android-ndk-r7/ndk-build

  • Error(Only in Android-ndk-r7):
  • You may get some error like the following
    • /awk.exe: can't open file check-awk.awk
    • Andoid NDK: Host 'awk' tool is outdated. Please define
    • HOST-Awk to Point to Gawk or Nawk !
  • Resolution:
    • Goto the android-ndk/prebuilt/windows/bin/
    • Change the awk.exe to awk_.exe

  • Now you may see the following output after successful execution
  • After successful creating libSampleNDK.so file, refresh your Eclipse project
  • You can see the updated "Project Explorer" with "libs" folder in the tree hierarchy
  • Update the java source code now by adding this library to it
Source code of SampleNDKActivity.java
package com.samplendk;

import android.app.Activity;
import android.app.AlertDialog;
import android.os.Bundle;

public class SampleNDKActivity extends Activity {
   
    static
    {
        System.loadLibrary("SampleNDK");
    }

   
    //Declare the native method
    private native String invokeNativeFunction();
   
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        //Call the native methods
        String hello = invokeNativeFunction();
        new AlertDialog.Builder(this).setMessage(hello).show();
    }
   
}

  • Clean the project by Selecting "Project"->"Clean"
  • Run the application as "Android Application"
  • Note:
    • Error:
      • java.lang.unsatisfiedLinkError Library -- not found
    • Resolution:
      • Please see if you have added the "lib" in java source before adding the library in System.loadLibrary() method
  • Please find the screenshot of above running program in emulator


If you have queries, please mail to psrdotcom@gmail.com

Eclipse C C++ CDT Plugin Download and Installation with Link or Location Problem Solution

Hi all,

If you are using Eclipse with Java or any other platform and you are planning to install the C/C++(CDT) Plugin then please follow the steps.

Installation Steps:
  • In Eclipse, Click the Help->"Install New Software"
  • You will get a Install named window
  • Click "Add" button
  • Please remove the dot(.) at the end while adding the CDT Plugin location from the link.
  • In "Install" Window, "Work with" textbox, please type the CDT and you will prompted with different options, Select the desired option and click/hit "Enter/Return" button.
  • It will show the similar kind of screen as shown below
  • You can select the all/desired tools to download
  • Please "Restart Eclipse" to complete the CDT Plugin installation for Eclipse
  • Now you can develop your C/C++ applications with Eclipse

Happy Coding ..


For further queries, please mail to psrdotcom@gmail.com

December 28, 2011

Facebook Timeline Feature Wall Design Update Procedure

Hi all,

Today I have update the new Facebook Timeline Feature. You can also update to Facebook Timeline but it is allowing us to use a trail period of 7 days. Hope this layout wall design will be liked by more persons?

Steps to update the Facebook Timeline:
  • Login with your username and password into Facebook
  • Type "Timeline" in the search box (top)
  • Select the "Introducing Timeline" as shown below

Please send your feedback to psrdotcom@gmail.com

December 27, 2011

Java Native Interface (JNI) in Netbeans with C/C++ and Java Hello World Sample Source Code

Hi all,

Today I configured the Netbeans IDE to work with Java Native Interface (JNI).

Pre-Requisites:
  1. Java Development Kit (JDK)
  2. Cygwin (or) MinGW & MSYS
  3. NetBeans IDE with Java and C/C++ Bundle

Installation:
  • Install JDK
  • Install Cygwin (or) MinGW&MSYS
  • Note: While installing please choose the destination directory name without spaces
  • I have installed NetBeans IDE All Version, because I thought, I will need all the technologies. That is different approach.

Configuration:
  • Set the environment variables like JAVA_HOME and PATH with Java Installation Directory and JDK bin, Cygwin/MinGW&MSYS bin directories respectively
  • Cygwin/MinGW integration with NetBeans
  • Configure the C/C++ with Tools MinGW bin directory, which automatically fills the corresponding compilers

Source Code:

  • Create a sample java application with the following detail

package javaapp1.JavaApp1;

public class JavaApp1
{
public static void main(String [] args)
{
  new JavaApp1.nativePrint();
}

private native void nativePrint();
}

  • Clean and Build the java project
  • In Command Prompt, Navigate to Netbeans Project Directory
    • cmd> cd Netbeans/ProjectDir
  • Create the Java header file
    • cmd> javah -o JavaApp1.h -classpath JavaApp1\build\classes javaapp1.JavaApp1

  • Create a C/C++ Dynamic Library Project in Netbeans (In this example, it is CppDll1)
  • Change some of the project properties
  • Make sure that, you have downloaded and configured the proper Cygwin/MinGW with exact Architecture 32bit/64bit
  •  Make sure that you are using proper gcc for 32bit/64bit dll creation
  • Linker must be of same architecture, 32bit/64bit


  • Include the Java header file, which we have created in Java Project.
    • Right click on the "Source Files"-> Select "Add an Existing Item"
    • Select the created header file from Project Home Directory
    • (OR)
    • Manually copy the created header file from Project home directory to CppDll directory
  • Create a C Source file in "Source Files" in CppDll1 project
 #include "JavaApp1.h"

JNIEXPORT void JNICALL Java_javaapp1_JavaApp1_nativePrint(JNIEnv *env, jobject obj)
{
    printf("\nHello World from C\n");  
}
  • Clean and Build the C code. I have faced the following issue.
    • Issues Faced:
      • I am using Windows 7 64-bit and installed Jdk 64-bit. But initially I have installed MinGW 32 bit and it is generating only 32 bit DLL which is not suitable to run the Java application in NetBeans.
    • Resolution:
      • Downloaded MinGW 64 bit and configured in the NetBeans C/C++ Options
  • Copy the .dll file path
  • In Java project, open the main class and add the following content
package javaapp1.JavaApp1;

public class JavaApp1
{
static
{
  System.load("dll file path");
}
public static void main(String [] args)
{
  new JavaApp1.nativePrint();
}

private native void nativePrint();
}
  • Clean and Build the project
  • Run the Java project to see the final JNI output.

References:
http://java.sun.com/docs/books/jni/html/jniTOC.html
http://java.sun.com/developer/onlineTraining/Programming/JDCBook/jni.html
http://www.cygwin.com/
http://sourceforge.net/projects/mingw-w64/
http://netbeans.org/community/releases/71/install.html

Please send your feedback to psrdotcom@gmail.com

December 24, 2011

Customize Command Prompt in Windows 7 with your own Icon, Starting Directory and more settings ...

Hi all,

Are you getting bored with the same command prompt with black colored background and other settings?

You can customize your own command prompt and you can start from the preferred location (Directory) path, choose your own icon and lot more.

Go ahead by following the below steps ..


Creating the shortcut icon on Destop
  1. Right click on the desktop, select "New" -> "shortcut"
  2. Browse for the command prompt executable file "cmd.exe"
  3. If you have installed your Operating System in C drive then the path might be similar to this
  4. C:\Windows\System32\cmd.exe
  5. Click on "Next"
  6. Type the name for this shortcut, something like "MyCmdPrompt"
  7. Click on "Finish"
  8. Now you can see your command prompt named of your own choice
  9. Now, you can change some properties of your command prompt

Changing the properties of the custom command prompt

  • Right click on the newly created shortcut from the Desktop
  • Select "Shortcut" tab and change the following settings
  1. Change the starting directory: Specify your own choice of directory path in the "Start in" box.
  2. Default Start in path: C:\Windows\System32
  3. Change the icon of your own choice: Click on "Change Icon" and Click on "Browse" button and Select the "C:\Windows\System32\imageres.dll" to list all the windows installed icons.
  4. Select an icon of your own choice and Click on "Ok"
  5. Run as Administrator by default: Click "Advanced" button, Select "Run as administrator" and Click "Ok"
  • Select "Options" tab and change the following settings
    1. Check "Quick Edit mode" to copy and paste easily
  • Select "Font" tab and change the following settings
    1. select your desired "Font" and "Size" settings
  • Select "Layout" tab and change the following settings
  1. select your desired "Window Size"
  2. Note: To see a bigger screen, increase the "Width and Height" attributes of the "Window Size"
  3. You can preview, your settings in the left side preview
  • Select "Colors" tab, You might be bored by seeing the same black and white combination.
  1. Choose your desired colors for Background, Foreground colors for both the "Screen" and "Pop-Up screen"
  • Click on "Apply" and then "Ok" to see your own command prompt.

Hope this post is useful to you customize your own Command Prompt in Windows 7.

For further queries, mail to psrdotcom@gmail.com

December 22, 2011

Netbeans Plugin Install, Update, Problem, Troubleshoot

Dear all,

I was facing an issue while updating my netbeans. It was showing the following screen


I tried to  resolve this problem by checking the proxy configuration, firewall configuration, refreshing the content. None of them solved my problem.
Note: You please try all those settings, it may work for you. If none the above configuration solves your problem then follow the below solutions.


I have found 2 solutions to resolve/troubleshoot this problem.

a) Manual Update
  1. Copy the path of the networking problem link
  2. Download the .nbm file
  3. In Netbeans, Click on Tools (Menu) -> Select "Plugins" option
  4. Select the tab "Downloaded" -> Click "Add Plugins"
  5. Choose the appropriate .nbm file from the downloaded directory
  6. Click "Open" to view in the "Downloaded" tab
  7. Check the plugin and Click on "Install" button
  8. Now the Netbeans plugin will be updated and it will auto download the dependencies
Note: Above Screens are of Netbeans IDE 7.0.1. For your netbeans IDE the options may be different menus but the procedure is same.
  • Pros: Easy to install the specified/chosen plugin and update
  • Cons:
    • Issue: While updating, if it was not able to get the dependency, then it will show the same "Networking Problem"
    • Resolution: Follow the same procedure from step 1

b) Automatic Update:

  1. In Netbeans, Click on Tools (Menu) -> Select "Plugins" option
  2. Select the tab "Settings"
  3.  
  4. Click "Add" button to add a plugin update center
  5.  
  6. Enter the name and path of the plugin update center and Click on "OK"
  7. It will auto-refresh the plugins available
Install Plugin:
You can download many netbeans plugins from "Available Plugins" tab of "Plugins" window.
Install your own choice of plugins and enjoy application development with Netbeans.

If you have any queries, please contact me on psrdotcom@gmail.com

December 19, 2011

Converting Power Point Presentation (PPT) to Images and Conversion of Images to PPT

Hi all,
Today I was searching for converting the slideshow to images and doing some batch processing to the images like crop, resize, filename change and again making ppt with the modified images.

I followed the below procedure to convert my slides in ppt to images, cropping the images and finally making slideshow with edited images.
  • Converting slides to images
    1. (MS Office 2007) Office Button (Top-Left) -> Save As ->  Other Formats
    2. Choose the corresponding destination folder
    3. Choose "Save as type" as "JPEG File Interchange Format (*.jpg)"
    4. One pop-up comes with the following options
      • Every Slide: This option saves every slide to an individual image
      • Current Slide: This option saves only the current slide to an image
    5. Choose relevant option to you
  • Batch Processing the images
    1. I have seen one video from youtube and I was impressed with the Irfan View working with batch processing of images
    2. Please see the below video and do the batch processing of images
  • Uploading images to PPT
    1. (MS Office 2007) Click on "Insert" tab and select "Photo Album" -> "New Photo Album"
    2. Select the image(s), which you would like to add in the presentation.
This kind of approach makes our lives easy.


If you have any queries, please mail to psrdotcom@gmail.com

December 17, 2011

Write in Telugu in your computer, website, blog for e-readers and e-writers

Hi Telugu e-writers,

I found something very interesting for you in Hyderabad Book Fair 2011.

There are some stalls for Telugu language where they are offering us to read, write in Telugu in our computer.

Please visit  http://etelugu.org/ link to use the computer in Telugu language.

If you are interested to write in Telugu http://etelugu.org/typing-telugu

Debian Operating System is customized with Telugu font and all the menus and typing has been done in Telugu.The Operating System CD costs Rs. 100/-

References:
http://etelugu.org/
http://etelugu.org/typing-telugu
http://telugublog.blogspot.com/2006/03/xp.html

Type in Indian languages in Computer Applications like MS Word, Notepad, Browser etc

Hi all,

I am very happy to share this information. We sometimes feel like typing the content in our native speaking language. Now we can type in our native language by using any one of the following tools.

I personally tried with Google IME and I am impressed on Windows 7 Professional

Google IME Installation:
  1. Download the Google IME from this link http://www.google.com/ime/transliteration/
  2. Select your OS type (32-bit/64-bit)
  3. Click on "Download Google IME"
  4. Install the software and the installation will take sometime.
Note: For more detailed Google IME installation steps, please visit this link

Microsoft Indic Language Input Tool Installation:
  1. Download the tool from this link http://specials.msn.co.in/ilit/Telugu.aspx
  2. You can see two versions of downloads
  3. Web Version -- Browser
  4. Desktop Version -- Computer PC
  5. Download the relevant version for you and install it
Vishal's Pramukh:
Download the different versions of tools for your individual purposes like browser, JavaScript development library, HTML Editor
Download Link: http://www.vishalon.net/Download.aspx



Typing in Desired Language:
  1. Right click on the taskbar -> Select Toolbars -> Select Language Bar
  2. You will find the language bar with currently using language for typing the content. Default: EN (English)
  3. Open the Microsoft Word
  4. We can change the language by selecting the EN from taskbar to Desired Language which are listed.
  5. Type in your language by following the suggestions while typing in English.

If you find any difficulty in typing your native language, please mail to psrdotcom@gmail.com 

References:
http://www.google.com/ime/transliteration/
http://www.google.com/ime/transliteration/help.html
http://specials.msn.co.in/ilit/GettingStarted.aspx?languageName=Telugu&redir=true&postInstall=false
http://www.vishalon.net/Download.aspx

Adobe Digital Editions free eBook, Digital Publications reader

Hi all,

We can download free eBook reader called from Adobe Digital Editions. It is awesome to use and read the eBook from it. You can purchase the digital eBooks and read from it.

Installation Steps:
1) Please visit this http://www.adobe.com/products/digitaleditions/
2) In the "Install Digital Editions" Section, One separate frame named "Adobe Digital Editions Installer" with any one of the following

  a) System (Error):
      "Sorry, but your system does not meet the minimum system requirements"
  b) Install: Click on install to to start the installation
       -> Download the executable and Install the software
       -> Give your Adobe ID if exists at the time of installation
  c) Launch: If the software already installed, it will launch the application
3) For testing, you can download the sample eBooks from adobe digital editions sample library
4) Click the downloaded item to view in Adobe Digital Editions

Enjoy the eBook reading. The digital editions available in different languages.

References:
http://www.adobe.com/products/digitaleditions/
http://www.adobe.com/products/digitaleditions/library/

December 16, 2011

Hyderabad Book Fair / Festival 2011

Hi all,

Today I have visited Hyderabad 26th Book Festival at People's Plaza, Neckles Road, Hyderabad.
I come to know about this book festival, through my friend.

The book festival dates and timings as follows:

Dates:
15 December 2011 to 25 December 2011

Timings: 
2PM to 9PM (Monday to Friday)
12Noon to 9PM (Saturday and Sunday)

There are different types of books available for pre-school children to retired persons.

Those who wants to buy Telugu, English novels and Spirtual, Devotional books, they must visit the book festival.

I have bought Swami Vivekananda Auto Biography and Swamy Ramakrishna Paramahamsa Biography books.
Since, It was a book festival, they gave 10% discount also.

Note:
If you buy books worth more than Rs. 200 then please visit the Kinige, stall No. 109. You will get some gift amount coupon (send to e-mail) to buy e-books from Kinige Web Store

At Kinige stall, you can participate in quiz to answer a question. If you are unable to choose the correct answer they will give another chance with another question. If you can answer any one the question, then you will get gift amount (send to e-mail) to buy e-books from Kinige Web Store.

You need to create an account in Kinige and then Recharge your account with the coupon to buy the e-books. You need to install adobe digital editions to view the e-book.

Please hurry up and buy your own books.

References:
http://hyderabadbookfair.com/
http://kinige.com/

If you have any queries, please mail to psrdotcom@gmail.com

December 14, 2011

Book Aakash and Pre Order UBISlate 7, Low cost Android tablet in India

Hi all,
If you want to use cheap and best Android tablet in India, then go for Aakash and UbiSlate 7 ( An upgraded version of Aakash ).

Aakash Details:

1) Runs on Android 2.2 (Froyo)
2) Wi-Fi Connectivity
3) External Memory Card Support (2GB - 32GB)
4) Cost: Rs. 2500/- (Pay cash on delivery)

Pros:
i) Very low cost tablet
ii) External memory support

Cons:
i) Less battery backup
ii) No phone functionality

UbiSlate 7 Details:

1) Runs on Android 2.3 (Gingerbread)
2) Phone functionality with SIM card
3) GPRS, Wi-Fi connectivity
4) Cost: Rs. 2999/- (Pay cash on delivery)

Pros:
i) Phone call facility
ii) GPRS connectivity
ii) Improved battery backup

Cons:
i) Android version

For more details about the Indian low price tablet Aakash and UbiSlate 7, please refer the original link
http://www.aakashtablet.com/

Order/Pre-book Details:


Aakash is already released and we can order now with the following link
http://www.ncarry.com/aakash-tablet-pc/billing-info.php
Note: Timings 8AM to 8PM only


UbiSlate 7 is ready to launch in January 2012 and we can pre-order with the following link
http://www.ubislate.com/prebook.html

Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com