Thursday, 31 October 2013

How to make java program run as a service/daemon in linux

Create a shell script as below
Now move this file to init.d location and issue update command to automatically start this as service when system reboots.

Thursday, 17 October 2013

Connecting to Plesk Mysql through Command Line

Connecting to Plesk Mysql though Command Line:

     Connection to plesk mysql on ubuntu systems doesn't work in the usual way. Plesk mysql password is stored in a different location and its encrypted too. So we can't keyin the normal password through commandline unless you know the complete encrypted form.So, mysql -u root -p command is not going to work for you. Use the below command to connect to plesk mysql on ubuntu systems through command line. /etc/psa/.psa.shadow ( this is the place where your plesk mysql password is stored ). Use "cat" command to print the password right after -p.

  mysql -uadmin -p`cat /etc/psa/.psa.shadow`  

Sunday, 6 October 2013

Install Android in NetBeans 7.3

Android in Netbeans 7.3

Please follow the below steps to install Android in NetBeans 7.3


  Open Netbeans, Go to Tools->Plugins, and select Settings Tab, Click on Add button

Step 2:

  In URL field, paste the below url     

  In Name Field, "Android"

Step 3: 

  Now go to Available Plugins tab and search for "Android", select android plugin and click Install button and restart NetBeans.

Step 4:

  Create new android project: 
      select "Android" category and "Android Project" from Projects section.

Step 5: Provide project Name, Location, package name, main activity and select android target platform.

 If Android SDK is not configured, Please go to android developer site and download the latest android sdk

and configure its path in netbeans ( Go to Tools->Options and select Android tab )

Thursday, 3 October 2013

Glassfish 4 and Primeface 4.0.RC1 fileupload issues

Glassfish 4 and Primeface fileupload issues!

Maven dependencies:


uploadFile.getContents() method is not working in primeface 4.0.RC1 version. To get the file content, use the below code:

private byte[] getFileContents(InputStream in) {

byte[] bytes = null;
try {
   // 277*121, 292*170, 327*143, 586*340
   // write the inputStream to a FileOutputStream            
   ByteArrayOutputStream bos = new ByteArrayOutputStream();
   int read = 0;
   bytes = new byte[1024];

   while ((read = != -1) {

bos.write(bytes, 0, read);
   bytes = bos.toByteArray();
   in = null;
   bos = null;
   logger.debug("New file created!");
} catch (IOException e) {
return bytes;