Example of creating JSON Array in JAVA

To know more about JSON , read “What is JSON and Understanding JSON syntax with simple example” and “Cloud Technologies” In this post, we will show you how to write a simple JSON Array by writing code in JAVA. This post is related to our previous post “Example of creating simple JSON in JAVA” Lets … Read more

Example of creating simple JSON in JAVA

To know more about JSON , read “What is JSON and Understanding JSON syntax with simple example” and “Cloud Technologies” In this post, we will show you how to create a simple JSON by writing code in JAVA, Here, the JSON object is created as, now, the JSON elements can be added to this object … Read more

How to generate random number between two numbers in Java ?

This post demos how you can get the random number between two numbers in a simple java program. When you are feeding some dummy data to something, you are required to simulate the inputs for your project / product. So mostly this random numbers are used in such scenarios. $ vim RandomNumber.java [java] import java.lang.Math; … Read more

How to use Single Instance Class / Singleton class in Android / Java ?

The single instance classes are mostly used when you don’t know how to create a object of this class from some distant class or instead of allocating memory for the class, just create object once and use it till entire life of the application. The Single Instance class, also called at Singleton class just creates … Read more

Java programming with Java Native Interface ( JNI ) / Calling Native C functions from JAVA using JNI

JAVA and JNIpre-requisite – Install Java SE Development Kit 6u14 under /usr/jdk1.6.0_14Write a JAVA class [ HelloWorld.java ] [java] public class HelloWorld { static { System.loadLibrary("hello"); } public native void printHelloWorld(); } [/java] Compile the class using javac sudo javac HelloWorld.java after this HelloWorld.class file should get created.Create header file required for writing a native … Read more

Convert Byte Array to Hex using Java

The post briefs above how you can convert byte Array to Hex values and print those on terminal. You are mostly be needing this conversion when you work closely with byte operations like as needed in network communications etc. We will take the same example as we used in our another post “Byte Array To … Read more

Byte Array To Integer And Integer to Byte Array Conversion using JAVA

If you are working in some network related data transfer like sending some commands over socket, then its high likely that you will need to convert your integer command number to byte array before sending over socket since data sent over socket is only byte arrays. Following program briefs above how you can convert Byte … Read more

How to Switch between Java Versions on Ubuntu Linux ?

If you have installed multiple JDK on ubuntu and sometimes you might need to change the version of installed JAVA to get few things working with one version and few other things working with another version of JAVA. Lets first identify which all JDK are installed on your ubuntu, this can be done using “update-java-alternatives … Read more

How to check if Filepath is Normal File or Directory in JAVA ?

In our previous post, we seen how to identify if a file is present or Not using JAVA If you want to check whether certain filepath is a normal file or is a directory present in your disk before proceeding further to do some operations in JAVA, the java.io.File class provides an API “isFile()” and … Read more