Pages

Tuesday 16 October 2012

Free Folder or Directory Compare Tool / Utility



In software development sometimes we need to compare two folders which are having same files. The same case happened with me. So I have written simple directory compare utility.
This is an executable jar which compares two folders and list down the result in xls file. This is simply written in java and UI is in java swing so it will work in any OS.






Prerequisites to run the utility:


1) Set the PATH environment variable to Java\jdk1.6.0_24\bin\ to run executable jar.

2) Output is created in .xls format. So .xls editor is needed for reading excel file. Use Microsoft Excel for windows and OpenOffice for Linux.

3)While providing input, First directory should be the latest directory otherwise it will not show  the newly added files in result.


To Run the utility follow below steps:

1) Double click on executable jar or use command java -jar DirectoryComparator.jar to run using command line.

2) Input to utility:

1) Two directory paths for comparison.
Note*:First Directory should be the latest directory otherwise it will not show  the newly added files in result.

2) Path of result file which is a excel sheet. (no need to give extention to excel file)

3) Comma separated list of file extensions ( if this left empty it will compare all the files.)

 e.g. java,jsp,txt,jpeg.css that means it will compare these files only.

Below is screen shot of utility with input selected:

Directory Compare Utility



3)After filling all the inputs and hitting compare button.The popup will show the path of excel file and basic result of the comparison as shown in below image.
                     Folder Compare




4) Go to the excel file  and expand the columns to see the details. Excel sheet shows the following details.
a)Column  List Of Changed Files : path of files which are changed
b)Column  Added File List : Shows file which are newly added.
c)Column  Other Information Shows :
a)Number  of  files compared count.
b)Number  of  files differs count.
c)Number  of  newly added files  count.

directory compare



Advantages of this Utility:

1) Comparison is fast and generates simple excel sheet.
2) It gives list of newly added files.
3) Main advantage is  it has filtering option i.e if you want to compare java and jsp file only then give input as java,jsp in File with extension input field.

Disadvantages of this Utility:

1)If user want to find newly added files in a directory then user have to give that folder as a first input and the other folder as second. This means it will not list newly added files in second directory.


Click Below link to download executable jar:



If you have any problem running utility please let me know.
Comments would be appreciated.

Thanks

PermGen space exception



      PermGen space exception with Maven


  •  What is PermGen Space?

             PermGen Stands for  Permanent Generation. PermGen space is a part heap memory.It is used for storing metadata information like class definitions.

  •   Why this  OutOfMemoryError  exception occurs?

                       The OutOfMemoryError: PermGen Space error occurs when the permanent generation heap is full. Usually this error is caused by a memory leak.

  •    How To Fix this exception ?
               a)MAVEN   
                     If your are using maven you get this error create following  environment variable:

                           MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"

                       Here 128m is double of the default space.

                       Note*: If your using  eclipse for running maven command and setting the MAVEN_OPTS is not               
                   solving problem try to run your maven commands using command line,as sometime it does not  
                   works.

                 b)Tomcat
                       Open catalina.sh Or catalina.bat based on the OS  and change the JAVA_OPTS as follows:


JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 
-server -Xms1536m -Xmx1536m
-XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m 
-XX:MaxPermSize=256m -XX:+DisableExplicitGC"









                    

Monday 24 September 2012

Convert java util Date From one Timezone To another Timezone In Java

How to convert java.util date from one Timezone To another Timezone?



      Here is the simple method which converts one Timezone To another and returns util date. Also most important thing is that it handles daylight saving time (DSTwhile converting date.



/**
* Convert Date from one timezone to other timezone.
* This method also takes care of daylight saving time
* @param dt
* @param from
* @param to
* @return
*/
public static Date convertFromOneTimeZoneToOhter(Date dt,String from,String to ) {

      TimeZone fromTimezone =TimeZone.getTimeZone(from);//get Timezone object
      TimeZone toTimezone=TimeZone.getTimeZone(to);
             
      long fromOffset = fromTimezone.getOffset(dt.getTime());//get offset
      long toOffset = toTimezone.getOffset(dt.getTime());
     
      //calculate offset difference and calculate the actual time
      long convertedTime = dt.getTime() - (fromOffset - toOffset);
      Date d2 = new Date(convertedTime);
     
      return d2;
}