Friday 27 September 2013

Program - Java Magic Word - cafebabe

import java.io.*;

public class MagicWord{
public static void main(String args[]) throws Exception{
FileInputStream fis=new FileInputStream("MagicWord.class");
int ch;
int count=0;
while((ch=fis.read())!=-1){

System.out.printf("%x",ch);
count++;
if(count==4)
break;
}
}
}

Thursday 26 September 2013

Simple simulation for how trial software program works in java

import java.io.*;
class Welcome
{
 public void print(){
 System.out.println(“Welcome to learn java”);
 }
}
public class filedel
{
 public static void main(String args[]) throws Exception
 {
  String name=”magic1″;
  boolean flag=false;
  String str=”";
  StringBuffer bu=new StringBuffer();
  RandomAccessFile rand = new RandomAccessFile(“filedel.class”,”rw”);
  int i=(int)rand.length();
  rand.seek(0);  //Seek to start point of file
  for(int ct = 0; ct < i; ct++){
  byte b = rand.readByte();
  bu.append((char)b);
  if(flag==true)
  {
  rand.seek(rand.getFilePointer()-1);
  char out=(char)b;
  str=out+”";
  if(Integer.parseInt(str)==3)
  {
   rand.close();
   File f=new File(“filedel.class”);
   f.delete();
   break;
  }
  rand.writeByte(b+1);
  break;
  }
  if(bu.indexOf(“magic”)!=-1)
  flag=true;
  
  }
  System.out.println(“your currently running “+str+” time this program”);
  Welcome w=new Welcome();
  w.print();
  rand.close();
 }
}

1) save into filedel.java
2) javac filedel.java
3)
java filedel
java filedel
java filedel
java filedel

run class file more than  3 times. see what happen.

Wednesday 25 September 2013

program to find the square root of a given number without using library function

    #include<stdio.h>
    float SquareRoot(float num);
    void main()
    {
    float input, ans;
  
    ans = SquareRoot(9);
    printf("\n Square Root : %f", ans);
  
    }
    float SquareRoot(float num)
    {
    if(num >= 0)
    {
    float x = num;
    int i;
    for(i = 0; i < 20; i ++)
    {
        x = (((x * x) + num) / (2 * x));
    }
    return x;
    }
    }



Tuesday 24 September 2013

Given an array , find the nth largest and nth smallest number. Sorting should not be used

This is for 6 number you can make it as you want

void main(){
int a[]={8,4,6,7,4,1},i,l=0,s=0,count=1,flag=0,largest,smallest,ps,pl;
for(i=0;i<6;i++){
    if(a[l]<a[i]){
        if(flag){
            if(a[pl]>a[i])
            l=i;
        }
        else{
        l=i;
        }
    }
    if(a[s]>a[i]){
        if(flag){
            if(a[ps]<a[i])
            s=i;
        }
        else{
        s=i;
        }
    }
    if(i==5){
        count--;
        if(flag==0){
            smallest=s;
            largest=l;
            
        }
        if(count==0){
            break;
        }
        else{
            flag=1;
            pl=l;
            ps=s;
            l=smallest;
            s=largest;
            i=-1;
        }
       
    }
}
        
    
printf("small=%d big=%d",a[s],a[l]);
}



Kindly share your ideas...

Tuesday 17 September 2013

Installing Instances of Adobe Experience Manager(CQ5)

Two instance

1.   Author

2.   Publish

Installing an Author Instance

1.   Copy the  jar file and license properties file in one folder

2.   Change the jar file name into cq5-author-p4502.jar

3.   Double click the jar file or open respective folder in command prompt and give the command

32 bit machine - java -Xmx1024M -jar cq5-author-p4502.jar

64 bit machine - java -XX:MaxPermSize=256m -Xmx1024M -jar cq5-author-p4502.jar

Installing a Publish Instance

1.   Copy the  jar file and license properties file in one folder

2.   Change the jar file name into cq5-publish-p4503.jar

3.   Double click the jar file or open respective folder in command prompt and give the command

32 bit machine - java -Xmx1024M -jar cq5-publish-p4503.jar

64 bit machine - java -XX:MaxPermSize=256m -Xmx1024M -jar cq5-publish-p4503.jar

Note: Default username and password for Adobe CQ is admin/admin

 

Sunday 8 September 2013

JAVA – Just Another Virtual Architecture


Java is one of the most popular programming languages. Old name for java is OAK. It is one of the object oriented programming language. Lot of open source application are developed using java.

Java is platform independent language. Java program stored with .java extension(source code). Java compiler compiles source code and converts into class file. Class file load and execute using java interpreter. Java compiler is machine independent. Java interpreter is machine dependent (JRE).

Write a simple hello world program in java

public class HelloWorld{
          public static void main(String arg[]){
                   System.out.println(“HelloWorld”);
}
}

Step for compile and execute the java file

1.     Save the code as a HelloWorld.java
2.     Compile. cmd>Javac HelloWorld.java
3.     Run. cmd>Java HelloWorld

Note: After compile, you get HelloWorld.class file where you stored in the HelloWorld.java location. This class is machine independent you can copy and paste into some other machine and try to run.


Monday 2 September 2013

Some useful debugging links for Adobe CQ5 developer

1.  Change the different mode in CQ (Edit,Preview,Design,Publish)

     Ans: URL?wcmmode=(edit|preview|design|disabled)

2.  Remove the content finder from the loading

     Ans: remove /cf#/ from the URL

3.  You can't edit the component because of overlapping parsys you want edit the component

    Ans: URL?debug=layout

4.  Do You want to debug the HTML, CSS and JavaScript in Adobe CQ5

    Ans: URL?debugConsole=true

5.  For debugging purpose you want to include CSS and JS files as separate files(not a single clientlib.js or          clientlib.css file) in Adobe CQ5

    Ans: URL?debugClientLibs=true 

6.  do you want to display all clientlib directory inside Adobe CQ5?

    Ans: http://server/libs/cq/ui/content/dumplibs.html
      

Sunday 1 September 2013

Different Android Versions and their Names and Images


Android
Version
Name
Meaning of the Name in Image
4.4
KitKat
4.1-4.3
Jelly Bean

4.0.x
Ice Cream Sandwich
3.x.x
Honeycomb
2.3.x
Gingerbread

2.2
Froyo

2.0, 2.1
Éclair

1.6
Donut

1.5
Cupcake