Arduino Android Interfacing – Example Code and Troubleshooting

Arduino Android Interfacing – Example Code and Troubleshooting


Mobile phones playing key role in our day to day life, when Google presented Android to the world and aimed to make every phones smart the mobile industry started growing and today even a low end mobile is a smart phone. In this smartphones era hardware interfacing and automation using smart phones is emerging.

The future is in Artificial intelligence, your smart phones are really becoming smart day by day. In this article we will see how to interface Arduino with Android Smart phone. We will divide this article into three sections

Arduino circuit diagram, Arduino code and Android code. 

How Arduino-Android interfacing using HC 05  Works ?

   After doing proper connections and both Android and HC 05 bluetooth module are paired. The android code will infinitely keep listening to incoming data from HC05 bluetooth module. When a button is pressed in which is connected to Arduino a data will be sent from HC05 to android. android code will read the incoming data.

Devices and Softwares needed :

  • HC – 05 Bluetooth module 
  • Arduino Uno R3
  • Breadboard and Jumper wires
  • Arduino IDE

Block diagram for Arduino-Android interfacing

block diagram Arduino-Android

block diagram Arduino-Android

Arduino Circuit Diagram –

Connection details : 

HC – 05 GND          ————>  Arduino GND Pin

HC – 05 VCC (5V)   ————> Arduino 5V

HC – 05 TX               ————>  Arduino Pin 10 ( soft RX )

HC – 05 RX               ————>  Arduino Pin 11 ( soft TX )

HC – 05 Key (Pin 34 ) ————>  Arduino Pin 9

Arduino Circuit diagram

Arduino Circuit diagram




Arduino Code :

SoftwareSerial mySerial(10,11); 
int button=9; 
int buttonState=0; 

void setup() {

void loop() {    
  buttonState=digitalRead(button); //Reads data when button is pressed      

 if (buttonState==LOW) {          
     mySerial.write("1"); //Send data 1 to Android.          

Android Code :

Declare necessary variables
/*Adapter helps to get a handler for device object which can be used to communicate with Bluetooth module*/
private BluetoothAdapter btAdapter = null;
/* Socket is used to connect and to get output/input streams to write/Read data To/From Bluetooth module */
 private BluetoothSocket btSocket = null;

/* Output stream used to send data to Bluetooth module
 private OutputStream outStream = null;

/* input stream used to read data from Bluetooth module */
 private InputStream inStream;

// UUID is used as a key to connect to the device
 private static final UUID MY_UUID = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");

// Insert your server's MAC address
 private static String address = "00:00:00:00:00:00";
protected void onCreate(Bundle savedInstanceState) {
      btAdapter = BluetoothAdapter.getDefaultAdapter();
       runnable = new Runnable() {
           public void run() { 
             //Create a thread which infinitely listen to the incoming data
       thread = new Thread(runnable);
 public void onResume() {
  // Set up a pointer to the remote node using it's address.
   BluetoothDevice device = btAdapter.getRemoteDevice(address);
 // Two things are needed to make a connection:
 //   A MAC address, which we got above.
 //   A Service ID or UUID.  In this case we are using the
 //     UUID for SPP.
   try {
      btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
    } catch (IOException e) {
        errorExit("Fatal Error", "In onResume() and socket create failed: " + e.getMessage() + ".");
  // Discovery is resource intensive.  Make sure it isn't going on
  // when you attempt to connect and pass your message.
  // Establish the connection.  This will block until it connects.
  try {
    } catch (IOException e) {
   try {
     } catch (IOException e2) {
// Create a data stream so we can talk to server.
 try {
     outStream = btSocket.getOutputStream();
     inStream = btSocket.getInputStream();
 } catch (IOException e) {
//Run listen in different thread
 public void listen() {
    // Keep listening to the InputStream until an exception occurs
    while (true) {
        try {
           // Read from the InputStream
           byte buffer[];
           buffer = new byte[1024];
           //Read is synchronous call which keeps on waiting until data is available
           int bytes =; 
            if(bytes > 0){
              /*If data is non zero which means a data has been sent from Arduino to
               Android */
             //Do your stuff here
     } catch (IOException e) {
private void checkBTState() {
    // Check for Bluetooth support and then check to make sure it is turned on
    // Emulator doesn't support Bluetooth and will return null
    if (btAdapter == null) {
    } else {
private void sendData(String message) {
    byte[] msgBuffer = message.getBytes();
    try {
     } catch (IOException e) {
        String msg = "In onResume() and an exception occurred during write: " + e.getMessage();
     if (address.equals("00:00:00:00:00:00"))
             msg = msg + ".\n\nUpdate your server address from 00:00:00:00:00:00 to the correct address on line 37 in the java code";
        msg = msg + ".\n\nCheck that the SPP UUID: " + MY_UUID.toString() + " exists on server.\n\n";
         errorExit("Fatal Error", msg);

<span style="color: #ff0000;">App Manifest file :</span>
<span style="color: #000000;">Download Manifest file here :</span> <span style="text-decoration: underline;"><span style="color: #0000ff;"><a style="color: #0000ff; text-decoration: underline;" href="">Link


Troubleshooting Arduino HC 05:

There are many issues you might face and the troubleshooting techniques are as follows. 1. Some times Android and HC 05 will not connect ( android btSocket.connect();) might fail In this case unpair your HC 05 from android mobile and restart your Arduino(power off and power on). Pair again with android. If this doesn’t work then restart your mobile phone. 2. Some times android reads junk data even though data is not sent from HC 05. In this case also do the same stuff as described in above point. You can find many examples in –

Project done by :

1. Vidya

2. Savitri

3. Shabnam

4. Niharika

Basaveshwar Engineering College – Bagalkot

How To Make You Web Site Faster : HTML , Javascript Tricks

How To Make You Web Site Faster : HTML , Javascript Tricks


The performance of your web application is highly important factor to get more user visits, experts have given many advices to improve the performance of a web application and few are listed below.

1. Meta refreshMeta refresh is a method of instructing a web browser to automatically refresh the current web page or frame after a given time interval, using an HTML meta element with the http-equiv parameter set to “refresh” and a content parameter giving the time interval in seconds.

Avoid Meta refresh as much as possible. This will slow down your site.

2. @imports will synchronously load the style sheet, Avoiding @import will improve the performance of your site. Instead of @imports use LINK tag as follows

<link rel=’stylesheet’ href=’knowledge-cess-style.css’>

Than   <style> @import url(‘knowledge-cess-style.css’); </style>

3. Avoid use of multiple framework – Some people use JQuery for some functionality and DOJO for some functionality . Loading of framework will take time and your app becomes heavy. Stick to one framework.

4. Placing scripts at the end

Most people will load all their scripts at the beginning of the page. Load scripts at the end, some times it is not possible, it gives an error if a function being used in the page. In that case make two js files and keep necessary stuff in one js and load it at the beginning.

5. Use ‘differ’ attribute to if some scripts must be loaded at the beginning.

<script src=“knowledge-cess.js” defer></script>

6. To construct dynamic pages it is better to use .innerHTML rather than always creating DOM elements dynamically.

7. Referencing more DOM elements using document.querySelectorAll()

var matches = document.querySelectorAll("div.note, div.alert"); Reference

8. Use Javascript timers carefully. Don't let timers run unnecessarily.
9. Javascript animation and Math

Time to play with Math now, animation is nothing but playing with frames, higher the frame rate smoother the animation and more frames means more processing. The time interval we set for an animation should depend on screen refresh rate.

Understand how Javascript Animation related to Screen refresh rate 

Most screens have refresh rate of 60Hz, so 60 frames per second (60fps) is best frame rate.
Javascript timer will be set in milliseconds. so considering 1000ms and 60FPS which will give
1000ms/60fps = 16.7ms. so it is best timer value, so set 16.7ms or 17ms for your javascript timer while playing with animations.

function setInterval(function(){

10. Performance factor for PNG and JPG – PNG will be of more size compared to jpg but jpg uses more complicated decoding algorithm compared to png.

Image format PnG vs JPG and performance
The reason png size will be more is because png format will use lossless compression algorithm and jpg will use lossy compression algorithm.
11. Using requestAnimationFrame : Mozilla team proposed requestAnimationFrame method to over come from performance issues in javascript animations. Have a look into this Link
There Many more performance tuning techniques.Now let us look into some best practices of javascript


Best Practices in Javascript

 1. Use Shortcut notations

var cities = ["Bangalore","Delhi","Mysore"]


var cities = new Array();

2. Keep related stuff together

Best Practice – 

var settings = function(){
     var userDefaults = {
         categories: {"defaultCategory" : "xyz", "lastCategory":"pqr"},
         modules : {}

      function initUserDefaults(){ }

      function clearUserDefaults(){}
   } //End of settings

The above way is clean and better approach rather than separating all methods.

3. Do not use primitive types as objects

 var name = "Ram";  //Best practice
      var name = new String("Ram"); //Not recommended

4. Use === operator

   Always use === operator for comparison, It always converts (to matching types) before comparison.

   The === operator forces comparison of values and type:

 100 == "100" //true which causes problem most of the times
      100 === "100" //false Best Practice, strict type checking

5. Global Variables in Javascript

Global variables are not recommended, Avoiding global variables is best practice.

6. Using JSLint 

Identify most common problems in your javascript code using JSLint tool


Check : how Animation in javascript works and how CSS3 is better than jQuerylink 

Integrating Facebook In iOS Applications

Integrating Facebook In iOS Applications

Environment Setup :

Step1: Login into your Facebook developer account

Download Facebook iOS sdk –

Step 2: Go to My Apps and select your application ( If App is not created then do create new app)



Step 3: Go to facebook app settings page 

iOSFacebookIntegration - Settings page

iOSFacebookIntegration – Settings page

Step 4: Add new platform for iOS in settings page and fill the details

iOSFacebookIntegration - Platform

iOSFacebookIntegration – Platform


Step 5: Now copy the App ID generated and Display name




Step 6 : In your iOS project file set Facebook App ID and URL types as shown below. 

Inside iOS project set FacebookAppID and FacebookDisplayName 

Facebook Integration in iOS shows Blank Screen after login :

Setting FacebookAppId and FacebookDisplayName in iOS project plist file

This is most common problem many people face when Facebook is integrated in iOS application.

This is because the Facebook App id has not been set in plist file.

URL types and URL Schemes should be added

iOSFacebookIntegration - plist

iOSFacebookIntegration – plist


Facebook integration using Javascript library

If you are using javascript and web view then the screen black out issue can be fixed by specifying redirect URL as given below

This should work:

function loginUser()
 FB.login(function(response) { },
 {scope:'email', redirect_uri:'http://your-redirect-url'}); 

Amazon AWS EC2 Security Group and S3 Bucket Configuration

Amazon AWS EC2  Security Group and S3 Bucket configuration

Read our previous post : How to Create And Configure Amazon EC2 Free tier account

Amazon AWS is an awesome cloud service, It is worth writing a post on AWS service and its usage.

It is very easy to create an AWS account and use it, but most people will struck when its matter of security. Amazon setup is little bit complicated for security configuration. Please follow the steps given below to enable security group in your amazon cloud service.

Steps For Amazon EC2 Security Group:

Step 1: Go to your EC2 Service as shown in the image below



Step 2: Go to the section Security Group

Amazon Security Group

Amazon Security Group


Step 3: Enter Group Details 

Amazon Security group details

Amazon Security group details


Step 4: Add following rules 


  • Rule 1

 Type : HTTP

 Protocol : TCP

 Port Range : 80

 Source :

  • Rule 2

 Type : All traffic

 Protocol : All traffic

 Port Range : All traffic

 Source : Your Ip Address ( search in google What Is My IP, copy paste the same IP here )

  • Rule 3

 Type : SSH

 Protocol : TCP

 Port Range : 22

 Source : Your Security Group Id

  • Rule 4

 Type : MYSQL

 Protocol : TCP

 Port Range : Mysql port ( 3306 )

 Source : Your Security Group Id


  • Rule 1

 Type : HTTP

 Protocol : TCP

 Port Range : 80

 Source :

  • Rule 2

 Type : All traffic

 Protocol : All traffic

 Port Range : All traffic

 Source : Your Ip Address ( search in google What Is My IP, copy paste the same IP here )

  • Rule 3

 Type : MYSQL

 Protocol : TCP

 Port Range : Mysql port ( 3306 )

 Source : Your Security Group Id

Amazon S3 Bucket configuration

Step 1 : Go to Administration and Security from Amazon Services

Amazon S3 : IAM

Amazon S3 : IAM


Step 2 : Select Group from the IAM page

Step 3: Create new group, Give any name for the group

Step 4: The most important step is to set Policy type for the S3 bucket.

For file upload/download, Select AmazonEC2FullAccess

If this is done then your Amazon S3 is ready for use.

Step 5: Go to S3 service from the main menu

There create new bucket. Set permissions to your bucket as per your need.

File Upload to Amazon S3 bucket in Java 

Code Sample :

private static String bucketName = “”; //Give your YourS3Bucket name
private static String keyName = “”; // Give SomeKey

public final static String FOLDER_PATH = “TestFolder”;

public final static String rootServerURL = “”; //Your S3 Bucket Path =&gt; Your Amazon Instance / BucketName

BasicAWSCredentials awsCreds = new BasicAWSCredentials(“AccessKey”, “SecretKey”);

AmazonS3 s3client = new AmazonS3Client(awsCreds);

PutObjectRequest putObjectRequest = new PutObjectRequest(bucketName, keyName, fileObject);
putObjectRequest.withCannedAcl(CannedAccessControlList.PublicRead); // Read Permission for all

Lambda Expressions in java – A Java 8 feature

What are Lambda Expression – Java 8 new feature?

Lambda expressions refers to what we had anonymous classes in the older versions of java.

So the very next straight forward thing comes to our mind, if already java is having anonymous classes why a replacement for the same is needed?

Why are Lambda Expressions needed, even if anonymous classes already exist?

The answer goes very simple, Lambda expressions when used makes our code more lighter as compared to when we use anonymous classes.

For Example:

Consider there is a class called Person
To sort the Person class by name if we use anonymous class we have to use the following code

Collections.sort(list, new Comparator() {
  public int compare(Person p1, Person p2) {
       return p1.getName().compareTo(p2.getName());

But if we use Lambda expressions it will reduce to just 1 line, as show below,

Collections.sort(list, (Person p1, Person p2) -&gt; p1.getName().compareTo(p2.getName()));

reduces lot of bulky codes.

Lets Discuss one example in detail:

We all are aware of Service Oriented Architecture if not please go through the tutorial 

Calling services will always be time consuming (in general all network calls are considered slow), so we handle those requests asynchronously. If the call is asynchronous then in order to get the response from the service we expect a call back to be called which will return us the result.

The following example demonstrates rather tries to simulate such a scenario,
Consider the following class “ThreadCallableClass” which will make the call to service,

package com.dhi.callback;

public interface CallBack {
	void operationCompelte(String args);


package com.dhi.thread;

import java.util.concurrent.Callable;

import com.dhi.callback.CallBack;

public class ThreadCallableClass implements Callable<String>{
	public ThreadCallableClass(CallBack callBack) {
		this.callBack = callBack;

	CallBack callBack;

	String str;
	public String getStr() {
		return str;

	public void setStr(String str) {
		this.str = str;
	public String call() throws Exception {
		System.out.println("service is getting called with the value: " + str);
		//code to call the service to fetch some details
		return "return " + str;



package com.dhi.main;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import com.dhi.thread.ThreadCallableClass;

public class MainClass {

	public static void main(String[] args) {
		List<String> list = new ArrayList<>();
		for (int i = 0; i < 10; i++) {
			list.add("dhi" + i);

		ArrayBlockingQueue<Runnable> arrayBlockingQueue = new ArrayBlockingQueue<Runnable>(
		ExecutorService executorService = new ThreadPoolExecutor(10, 100, 20,
				TimeUnit.SECONDS, arrayBlockingQueue);
		for (String eachStr : list) {
			ThreadCallableClass callable = new ThreadCallableClass((String test1) -> {System.out.println(" call back getting called for the service for "+ test1);});
		System.out.println("after thread pool");


package com.dhi.main;


public class Person implements Serializable{
	String name;
	String mob;
	public String getName() {
		return name;
	public void setName(String name) { = name;
	public String getMob() {
		return mob;
	public void setMob(String mob) {
		this.mob = mob;


Download Code

Spring3 Issue with java8

Spring3 Issue with java8

Most common problem every one face during upgrading java to java8

Problem: All is well in your java spring3 web application, suddenly you start getting,

at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.asm.ClassReader.(Unknown Source)
at org.springframework.core.type.classreading.SimpleMetadataReader.(
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(
at org.springframework.core.type.classreading.CachingMetadataReaderFactory.getMetadataReader(
at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(
at org.springframework.context.annotation.ConfigurationClassParser.getImports(
at org.springframework.context.annotation.ConfigurationClassParser.getImports(
at org.springframework.context.annotation.ConfigurationClassParser.getImports(
at org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(
at org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(
at org.springframework.context.annotation.ConfigurationClassParser.parse(
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(
at org.springframework.web.context.ContextLoader.configureAndRefreshWebApplicationContext(
at org.springframework.web.context.ContextLoader.initWebApplicationContext(
at org.springframework.web.context.ContextLoaderListener.contextInitialized(
at org.apache.catalina.core.StandardContext.listenerStart(
at org.apache.catalina.core.StandardContext.startInternal(
at org.apache.catalina.util.LifecycleBase.start(
at org.apache.catalina.core.ContainerBase$
at org.apache.catalina.core.ContainerBase$
at Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)



This issue is due to update of java to java 8, Following are the solutions for the same,

  1. You still intend to use java8 then spring must be upgraded to 4 or
  2. Change back the version of java to java7.

Steps to change in eclipse,

  1. Right click on the project and goto properties.
  2. Select “Java Build Path”.
  3. Goto “Libraries” tab.
  4. Select JRE System Lib (sometimes the name will mislead, it will be showing java7 but internally it will be pointing to java8).
  5. Click on “Edit” button present on the right side.
  6. Select “Alternate JRE” and click on “Installed JRE”.
  7. Click on “Add” è “Standard VM”.
  8. Click on “Directory” and select the JRE7 home.
  9. An entry for jre7 will be present, check the check box present against jre7.
  10. Click “Ok”
  11. Click on “Finish”.
  12. Click “Ok” again.
  13. Click on “Project” menu and then “Clean”
  14. Wait till the build completes.

You are good with all now again.

Scalability, architecture , Multitenancy : Database

Scalability, architecture , Multitenancy : Database

Assume that you have multiple clients, each client has access to similar kind of data, so database architecture should remain same for every client. 

An example for the same is , assume that you have developed an ERP product for a company, many companies will be having same requirement so the database will remain same.

Most of the developers will be under confusion, whether to go for single instance of database or multiple instance of database. Following are the two approaches and their pros and cons.

Approach 1 : Single instance database

  Keeping single instance of database but providing client id for each client to keep track of data of each client. 

Advantages : 

1) Better resource utilization – If your database is hosted on cloud services, like Amazon then as you create more number of instances they will allocate resources accordingly and charges will be applied for each instance. 
Example – check pricing for db instance in amazon

2) Scalability – Scalability is more easy since single instance is maintained.

Problems : 

1) Security issues – since every client’s data is in the same instance, developers should be wise enough to take care of showing data to appropriate users. Highest risk factor with single instance is security

2) Data loss – if the instance fails due to some problems related to one client, it affects to every other client, so routinely back of database is must be taken care. No compromise with data loss.

3) Performance issue – For a huge set of data performance of database might be low ( this matters for very huge data, not even for medium scale database )

This is called as Multitenancy – a principle in software architecture where a single instance of the software runs on a server, serving multiple tenants.

Approach 2 : Multiple instances database

with this approach all the problems of first approach will be solved but the only problem with this approach is scalability.

Mathematics to solve real-world problem

Analysing problem of global warming using Mathematics

we studied mathematics in high-school, degree college but never tried to apply the concepts in real-world. I was just thinking what example I shall take and how to write a program for the same. I got to know an interesting problem, only the problem is interesting but in real the problem is really worrying.


in Arctic the ice surface reflects 90% of the radiation but the water surface reflects only 10% of the radiation. Considering the fact in last two decades the Arctic like places showing effect of climate change. The water surface absorbs 90% of the radiation and hence leads to chain reaction. Assuming for every 1000 gray radiation, 0.65 sqft/hr water formation from ice surface, to predict how much ice surface might vanish and what could be the impact on global warming in next two decades?

To solve this problem one must apply integration which we study in Mathematics calculus, the same problem in other way to find out the rate of change of water surface can be evaluated using differential calculus.

Let me try out this problem with a C program, definitely I still didn’t find the integration or differential calculus equation to solve, but let me prepare set of simulated data with certain assumptions.

C Program

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
    Ice surface - reflects 90% of the sun light
    Water surface - reflects 10% of the sub light
    100 ice surface             - 10% absorbs
    100 water surface           - 90%
    Radiation = 100 gray
    100 * 90 = 9000 gray
    100 * 10 = 1000 gray
    assume that as temperature decreases ice surface increases, at the rate say 0.6 sqft per 1000 gray
    float iceSurfaceArea;
    float waterSurfaceArea;
    float radiationQuantity;
    float iceSurfaceAbsorption;
    float waterSurfaceAbsorption;
    float waterFormationPerHour;
int main(int argc, const char * argv[])
    ICE_RADIATION_INFO iceRadiationSamples[100];
    short int index;
// Just to initialise the set of data for analysis - 
    for (index = 0; index < 100; ++index) {
        ICE_RADIATION_INFO  *iceRadiationSample = &iceRadiationSamples[index];
        // 1.5 is constant taken to generate area in floating point number
        iceRadiationSample->iceSurfaceArea = (rand() % 100) * 1.5;
        iceRadiationSample->waterSurfaceArea = iceRadiationSample->iceSurfaceArea;
        iceRadiationSample->radiationQuantity = (rand() % 1000) * 1.5;
      // absorption is as per discussion 90% from water surface and 10% from ice surface
        iceRadiationSample->iceSurfaceAbsorption = iceRadiationSample->radiationQuantity * 0.1;
        iceRadiationSample->waterSurfaceAbsorption = iceRadiationSample->radiationQuantity * 0.9;
    // with an assumption for every 1000 gray radiation, 0.65 sqft water forms
        iceRadiationSample->waterFormationPerHour = ( 0.65 * iceRadiationSample->radiationQuantity) / 1000; // 0.65 sqft/hr for 1000 gray
            Every hour 0.65 sqft water occumulation , this intern absorbs 90% of radiation , here have to apply integration
            dx/dt = 0.65
    printf("Surface Area \t Radiation \t\t Ice Absorption \t Water absorption\n");
    for (index = 0; index < 50; ++index) {
        ICE_RADIATION_INFO iceRadiationSample = iceRadiationSamples[index];
        printf("%f\t\t %f \t\t %f \t\t %f\n",iceRadiationSample.iceSurfaceArea,iceRadiationSample.radiationQuantity,iceRadiationSample.iceSurfaceAbsorption,iceRadiationSample.waterSurfaceAbsorption);
    return 0;


Surface Area              Radiation                    Ice Absorption                  Water absorption

10.500000                   373.500000                  37.349998                           336.149994

109.500000                 987.000000                  98.699997                            888.299988

45.000000                   408.000000                   40.799999                           367.200012

66.000000                   1317.000000                 131.699997                         1185.300049

34.500000                   1063.500000                 106.349998                         957.150024

Domain Transfer : One VPS web hosting account to another

Domain Name Server and Domain transfer

Normally what happens when you purchase a domain from one Vendor say Amazon, you will link the domain to you web hosting account.

But later you may stop using amazon hosting service but you find some other vendor for hosting. Say you go for squarebrothers.

In that case you will be having two options, either set your name servers to point them to your square brothers vps hosting account.

Let me briefly explain how exactly these domain names works 

Assume that you purchased a domain in amazon. It looks like below 

name servers

name servers

Which means amazon has dedicated three name servers to map your domain to system specific ip address. Everything in internet works with ip address, domain will be mapped to specific ip address but to translate an ip to human readable domain name name servers are required.

now your domain mapped to name servers of amazon, these name servers will be allocated for you when you purchase hosting account.

If you purchase an account in square brothers, they will provide few name servers for you, to map the domain which is there in amazon, you just need to set name servers of square brothers hosting account in amazon domain control panel.

Assume that square brothers have given ns.sqrbr.server1 and ns.sqrbr.server2 as name servers, set these to in amazon by replacing name servers given in the above fig.

This is just mapping domain name, in case if you want to transfer completely from one account to another you just need to disable privacy protection and theft protection in the closing account, and apply for domain transfer.

Jersey ClientHandlerException : A message body writer for Java type, class org.json.JSONObject, and MIME media type,

lientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.json.JSONObject, and MIME media type, application/json,

com.sun.jersey.api.client.ClientHandlerException: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.json.JSONObject, and MIME media type, application/json, was not found
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(
    at com.sun.jersey.api.client.Client.handle(
    at com.sun.jersey.api.client.WebResource.handle(
    at com.sun.jersey.api.client.WebResource.access$200(
    at com.sun.jersey.api.client.WebResource$
    at com.knowledgecess.test.service.impl.TestServiceImpl.getQuestions(
    at com.knowledgecess.test.action.TestAction.demotest(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(
    at java.lang.reflect.Method.invoke(
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(
    at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(
    at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(
    at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(
    at com.opensymphony.xwork2.DefaultActionInvocation.invoke(
    at org.apache.struts2.impl.StrutsActionProxy.execute(
    at org.apache.struts2.dispatcher.Dispatcher.serviceAction(
    at org.apache.struts2.dispatcher.FilterDispatcher.doFilter(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.valves.AccessLogValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.AbstractHttp11Processor.process(
    at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(
    at java.util.concurrent.ThreadPoolExecutor.runWorker(
    at java.util.concurrent.ThreadPoolExecutor$
Caused by: com.sun.jersey.api.client.ClientHandlerException: A message body writer for Java type, class org.json.JSONObject, and MIME media type, application/json, was not found
    at com.sun.jersey.api.client.RequestWriter.writeRequestEntity(
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler._invoke(
    at com.sun.jersey.client.urlconnection.URLConnectionClientHandler.handle(
    ... 74 more

Solution :
Just find jsonInput, second parameter for post() in the below code add toString to jsoninput data

ClientResponse clientResponse = webResource
                .post(ClientResponse.class, jsonInput);


ClientResponse clientResponse = webResource
.post(ClientResponse.class, jsonInput.toString());