Wednesday 12 September 2012

Eclipse local svn

just Right click on file

Select Compare With ---> Local history

:-) u have now local svn in eclipse





'Initializing Java Tooling' has encountered a problem in eclipse

go to the folder where your eclipse.exe or eclipse runnable file located.

and start eclipse with: eclipse -clean

Tuesday 11 September 2012

Run Class inside jar file

java -classpath <jar_file.jar> <class_in_jar_with_absolute_path>

Example:

t4acke4.jar Contents

com.example.XYZ1.class
com.example.XYZ2.class

com.example.test.PQR1.class
com.example.test.PQR2.class
com.example.test.PQR3.class

NOTE: Here com,example and test are folders or packages

Run PQR2 as:

java -classpath t4acke4.jar com.example.test.PQR2

Monday 10 September 2012

Run shellscript on Boot

Copy shellscript file to /etc/init.d/XYZ (XYZ is shellscript name)

vim /etc/init.d/XYZ and copy below two line on top of file
(Note: change value of 10 and 80 in below two lines to any random number it shoud not match with other file)

--------------------------------
#!/bin/sh
# chkconfig: 2345 10 80
--------------------------------
Then Execute below two commands:

1>chkconfig --add XYZ
2>chkconfig XYZ on



To check if added or not just execute below command
chkconfig --list | grep XYZ

Output :

XYZ 0:off 1:off 2:on 3:on 4:on 5:on 6:off 





If we wanted to turn XYZ off in run levels 3, 4, and 5, we'd use a command like this :

chkconfig --level 345 XYZ off

Create multiple objects in Java


Use of Interface in java.

Let's assume we have a Game Class and four subtypes of Game: Hockey, Cricket,Tennis,Football


public static List<Game> getInstances(Class<? extends Game> clazz, int counter)
{
    List games = new ArrayList<Game>();
    for(int i=0;i< counter; i++)
    {
        games.add(clazz.newInstance());
    }
    return games;
}

Now you can use this for creating games.

List<Hockey> hctf = Game.getInstances(Hockey.class,10);
List<Cricket> hctf = Game.getInstances(Cricket.class,10)
List<Tennis> hctf = Game.getInstances(Tennis.class,10)
List<Football> hctf = Game.getInstances(Football.class,10)

Testing your site's response time-PageSpeed,Check your site's performance


The speed of loading your site has a direct impact on the time visitors will spend on the site

Google came up with this great free project

https://developers.google.com/speed/pagespeed/insights

Content Assist (Ctrl + Space) Is Not Working in eclipse

                                   Ctrl + Space Is Not Working in eclipse


Select Preferences>Java>Editor>Content Assist



Select checkbox "Select Enable auto activation"

type .(dote) in "Auto activation triggers for java" show in image.