Monday, August 29, 2011

How to Develop Android Applications Using Eclipse IDE

Eclipse is a common Integrated Development Environment  acting as a platform to develop applications with GUI's.Eclipse IDE is also available for Java, for developing Java Applications.Since Android is an Operating System with Java Programming Interface ,applications for Android are mostly Coded in Java.In this Post i will show you how to Configure Eclipse for Developing Android Applications.

  • Enter this URL https://dl-ssl.google.com/android/eclipse/ or http://dl-ssl.google.com/android/eclipse/ into the text box corresponding to the works with label..


  • Wait for the Plugins to be listed ,Check the Boxes ,Click on Next.
  • Wait for the Installation to be completed.Done!Your IDE is ready for developing android apps. 

               

Java Program to Check whether a Expression is Valid using Stack

The Program given below can be used to check whether a given mathematical expression is valid or invalid.The Validation procedure is based on the presence of complementary opening and closing braces.This implementation makes use of stack to push and pop out opening and closing brackets to the stack, as they are encountered in the Expression String.This program pushes opening brackets to the stack and pops out closing braces,checking whether the complementary brace is present at the top of the stack.Finally if the stack is empty the Expression is valid else the Expression is Invalid.

sample Output:
Enter the string
(a+b)-c
Valid Expression

Enter the string
(a+b-c
Invalid expression
The Complete Source Code is Provided below
 import java.io.*;  
 import java.lang.*;  
 class array  
 {  
  DataInputStream get=new DataInputStream(System.in);  
  int n,i,top=0,f=0;  
  char a[];  
  String str;  
  void getdata()  
  {  
  try  
   {  
   a=new char[30];  
   System.out.println("Enter the string");  
   str=get.readLine();  
   n=str.length();  
  }  
  catch(Exception e)  
  {  
   System.out.println(e.getMessage());  
  }  
  }  
  void push(char c)  
  {  
   a[top]=c;  
   top++;  
  }  
  char pop()  
  {  
   char h;  
  if(top!=0)  
   {  
   top--;  
   h=a[top];  
   return h;  
   }  
  else  
  return 0;  
  }  
  int stempty()  
  {  
   if(top==0)  
   return 1;  
   else  
   return 0;  
  }  
  void operation()  
  {  
  char d,t;  
  for(i=0;i<n;i++)  
   {  
   d=str.charAt(i);  
   switch(d)  
     {  
     case '(':  
         {  
          push(d);  
          break;  
         }  
     case '{':  
         {  
          push(d);  
          break;  
         }  
     case '[':  
         {  
          push(d);  
          break;  
         }  
     case ')':  
         {  
          t=pop();  
          if(t!='(')  
          f=1;  
          break;  
         }  
     case '}':  
         {  
          t=pop();  
          if(t!='{')  
          f=1;  
          break;  
         }  
     case ']':  
         {  
          t=pop();  
          if(t!='[')  
          f=1;  
          break;  
         }  
     }  
     }  
  if(f==0&&top==0)  
  {  
   System.out.println("Valid Expression");  
  }  
  else  
   System.out.println("Invalid expression");  
  }  
 }  
 class validexp  
 {  
  public static void main(String arg[])  
  {  
   array obj=new array();  
   obj.getdata();  
   obj.operation();   
  }  
 }  

Sunday, August 28, 2011

Java Program to Perform Linear Search

Linear Search is a Sequential Searching algorithm, it is commonly used to find an element in an array.It works by checking whether each element in the array is equal to the element to be found.This done by Incrementing the Index of the array.If the element is found a flag variable is set to indicate the presence of the element and the index of the array ,where the element is found is reported.The Complete Source Code to implement Linear Search in java is provided below.
 import java.io.*;  
 import java.lang.*;  
 class Linear  
 {  
 DataInputStream get;  
 int a[];  
 int key,n,i;  
 void getdata()  
 {  
  try  
  {  
   get=new DataInputStream(System.in);  
   System.out.println("Enter the size");  
   n=Integer.parseInt(get.readLine());  
   a=new int[n];  
   System.out.println("Enter the elements");  
   for(i=0;i<n;i++)  
   a[i]=Integer.parseInt(get.readLine());  
   System.out.println("Enter the key element");  
   key=Integer.parseInt(get.readLine());  
  }  
  catch(Exception e)  
  {  
   System.out.println(e.getMessage());  
  }  
 }  
 void search()  
 {  
 int flag=0,j,i;  
 int pos[]=new int[10];  
 for(i=0,j=0;i<n;i++)  
  {  
  if(key==a[i])  
  {  
   flag=1;  
   pos[j]=i+1;  
   j++;  
  }  
  }  
 if (flag==1)  
 {  
  System.out.println("Element is found in position:");  
  for(i=0;i<j;i++)  
  System.out.print(pos[i]+" ");  
 }  
 else  
  System.out.println("Element not present in this array");  
 }  
 }  
 class Linearsearch  
 {  
 public static void main(String arg[])  
 {  
  Linear obj=new Linear();  
  obj.getdata();  
  obj.search();  
 }  
 }  

Wednesday, August 24, 2011

Java Program to Perform Infix to PostFix Conversion

The Program given below Converts an Infix Expression to Post Fix Expression.For eg: ((l+i)*n-(o-p)^(q+p)) would be Converted to li+n*op-qp+^- .The Complete Source Code is Provided Below
 import java.lang.*;   
 import java.io.*;
  class array   
  {   
  DataInputStream get=new DataInputStream(System.in);   
  int n,i,top;   
  char s[],a[];   
  String str;   
  void getdata()   
  {   
  try   
   {   
   System.out.println("Enter the expression:");   
   str=get.readLine();   
   n=str.length();   
   s=new char[40];   
   a=new char[40];   
  }   
  catch(Exception e)   
  {   
   System.out.println(e.getMessage());   
  }   
  top=0;   
  }   
  void push(char c)    
  {   
   s[top]=c;   
   top++;   
  }   
  char pop()   
  {   
   char h;   
  if(top!=0)   
   {   
   top--;   
   h=s[top];   
   return h;   
   }   
  else   
   return 0;   
  }   
  void operation()   
  {   
  int j=0;   
  char d=0;   
  char t;   
  for(i=0;i<n;i++)   
   {   
   t=str.charAt(i);   
   switch(t)   
    {   
    case'^':   
      {   
      push(t);   
      break;   
      }   
    case '(':   
      {   
      push(t);   
      break;   
      }   
    case '{':   
      {   
      push(t);   
      break;   
      }   
    case '[':   
      {   
      push(t);   
      break;   
      }   
    case ')':   
      {   
      while((d=pop())!='(')   
      {   
       a[j++]=d;   
      }   
      break;   
      }   
    case '}':   
      {   
      while((d=pop())!='{')   
      {   
       a[j++]=d;   
      }   
      break;   
      }   
    case ']':   
      {   
      while((d=pop())!='[')   
      {   
       a[j++]=d;   
      }   
      break;   
      }   
    case '+':   
      {   
      if(s[top]=='/'||s[top]=='*'||s[top]=='^')   
      {   
      a[j++]=pop();   
      }   
      push(t);   
      break;   
      }   
    case '-':   
      {   
      if(s[top]=='+'||s[top]=='/'||s[top]=='*'||s[top]=='^')   
      {   
       a[j++]=pop();   
      }   
      push(t);   
      break;   
      }   
    case '*':   
      {   
      if(s[top]=='^')   
      {   
       a[j++]=pop();   
      }   
      push(t);   
      break;   
      }   
    case '/':   
      {   
      if(s[top]=='^'||s[top]=='*')   
      {       
       a[j++]=pop();   
      }   
      push(t);   
      break;   
      }   
    default:   
      a[j++]=t;   
    }   
   }   
   while(top!=0)   
   {   
   if(s[top]!='(')   
   {   
    a[j++]=pop();   
    }   
   }   
    System.out.println("The postfix expression is:");   
    for(i=0;i<j;i++)   
    System.out.print(a[i]);   
  }   
  }   
  class postcon   
  {   
  public static void main(String arg[])   
  {   
  array obj=new array();   
  obj.getdata();   
  obj.operation();   
  }   
  } 

Sunday, August 21, 2011

Protecting Jar files from Decompilation by Code Obsfuscation using SmokeScreen

Today every program has a threat from decompilation and reverse Engineering.This threat is not limited to Executable(.exe) files ,Jar files (.jar) can be unpacked and reverse engineered easily than an Executable(.exe) file.The Java program source code can be easily be reconstructed from the class files.

This does not mean that .jar files are Insecure.Several methods can be used to Protect or Pack a Jar file.Code Obfuscation is means of protecting a Java File by Complicating or Obfuscation of the Source Code.Many code Obfuscation tools are available and Smoke Screen is one of it.

Smoke Screen has a clean user Interface and Codes can be obfuscated with the click of button.You can get Smoke Screen from its official website http://www.leesw.com/smokescreen/ 

Now i will tell you how to protect a .jar file by using smokescreen

1)Open Smoke Screen and Select the Jar file you want to Protect by Clicking the Browse Button Next to the Source Tab.

2)Give the Name and Path of the Protected /Obfuscated Jar file By Clicking the Browse Button next to the Destination tab.

3)Click on Start.Wait for the Process to Finish.Done! The Protected jar file can be obtained from the Destination location you specified.

Friday, August 19, 2011

Java Program to Impliment Circular Queue

The Java Source Code given below can be used to Implement a Circular Queue.
 import java.io.*;  
 import java.lang.*;  
 class clrqueue  
 {  
  DataInputStream get=new DataInputStream(System.in);  
  int a[];  
  int i,front=0,rear=0,n,item,count=0;  
  void getdata()  
  {  
  try  
   {  
   System.out.println("Enter the limit");  
   n=Integer.parseInt(get.readLine());  
   a=new int[n];  
   }   
  catch(Exception e)  
   {  
   System.out.println(e.getMessage());  
   }  
  }  
  void enqueue()  
  {  
   try  
   {  
   if(count<n)  
    {  
    System.out.println("Enter the element to be added:");  
    item=Integer.parseInt(get.readLine());  
    a[rear]=item;  
     rear++;  
    count++;  
    }  
   else  
    System.out.println("QUEUE IS FULL");  
   }  
  catch(Exception e)  
   {  
   System.out.println(e.getMessage());  
   }  
  }  
  void dequeue()  
  {  
   if(count!=0)  
    {  
    System.out.println("The item deleted is:"+a[front]);  
    front++;  
    count--;  
    }  
   else  
    System.out.println("QUEUE IS EMPTY");  
  if(rear==n)  
   rear=0;  
  }  
  void display()  
  {  
   int m=0;  
   if(count==0)  
   System.out.println("QUEUE IS EMPTY");  
   else  
   {  
   for(i=front;m<count;i++,m++)  
   System.out.println(" "+a[i%n]);  
   }  
  }  
 }  
 class myclrqueue  
 {  
  public static void main(String arg[])  
  {  
  DataInputStream get=new DataInputStream(System.in);  
  int ch;  
  clrqueue obj=new clrqueue();  
  obj.getdata();  
  try  
  {  
   do  
   {  
   System.out.println(" 1.Enqueue  2.Dequeue  3.Display  4.Exit");  
   System.out.println("Enter the choice");  
   ch=Integer.parseInt(get.readLine());  
   switch (ch)  
   {  
   case 1:  
       obj.enqueue();  
      break;  
   case 2:  
      obj.dequeue();  
      break;  
   case 3:  
      obj.display();  
      break;  
   }  
   }  
   while(ch!=4);  
  }  
  catch(Exception e)  
  {  
  System.out.println(e.getMessage());  
  }  
  }  
 }  

Binary Search Program Source Code in Java

The Java Program given below can be used to find an Element in array using Binary Search Technique.
The Main steps Involved here are
1)A Pivot Element is Found
2)The array is sorted in such a way that elements greater than the pivot lies to the right and elements lesser lies to the left of the pivot.
3)Linear search is applied by taking the appropriate limits.,depending upon whether the element to be searched is greater or lesser than the pivot. 
 class array  
 {  
  DataInputStream get;  
  int a[];  
  int i,j,n,key;  
  void getdata()  
  {  
  try  
  {  
   get=new DataInputStream(System.in);  
   System.out.println("Enter the limit");  
   n=Integer.parseInt(get.readLine());  
   a=new int[n];  
   System.out.println("Enter the elements");  
   for(i=0;i<n;i++)  
   a[i]=Integer.parseInt(get.readLine());  
  }  
  catch(Exception e)  
  {  
   System.out.println(e.getMessage());  
  }  
  }  
 void sorting()  
 {  
 int t,j;  
 for(j=0;j<n;j++)  
 {  
  for(i=0;i<n-1;i++)  
  {  
  if(a[i]>a[i+1])  
   {  
   t=a[i];  
   a[i]=a[i+1];  
   a[i+1]=t;  
   }  
  }  
  }  
  System.out.println("Elements in ascending order is:");  
  for(i=0;i<n;i++)  
  System.out.print(a[i]+" ");  
  System.out.println();  
  try  
  {  
  System.out.println("Enter the key element");  
  key=Integer.parseInt(get.readLine());  
  }  
  catch(Exception e)  
  {  
   System.out.println(e.getMessage());  
  }  
  }  
  void search()  
  {  
  int m,flag=0,l,u,p=0;  
  l=0;  
  u=n-1;  
  while(l<=u)  
  {  
   m=(l+u)/2;  
   if(a[m]==key)  
   {  
   flag=1;  
   p=m+1;  
   break;  
   }  
   else if(a[m]<key)  
   l=m+1;  
   else  
   u=m-1;  
  }  
  if(flag==0)  
   System.out.println("The number is not found");  
  else  
   System.out.println("The number is found in:"+p);  
  }  
 }   
 class binarysearch  
 {  
 public static void main(String arg[])  
 {  
  array obj=new array();  
  obj.getdata();  
  obj.sorting();  
  obj.search();  
  }  
 }  


Which is the Best Photo Watermarking Software

Photo Theft is becoming more and more common in the web with the outburst of social websites like Facebook,Google Plus and Image sharing se...