Skip to main content

Posts

Showing posts from February, 2014

Create,Delete and Compile by ANT build file.(Ant Part-3)

In our last post we have seen 
What is Ant("Another Neat Tool")?How to configure it in your machineNow we will see some core task which can be performed by using ant such as create a folder or delete folder and to compile the java source.If till now you have not got 1% idea about ANT don't worry it is not needed also just check the below XML build file.

<?xml version="1.0"?><projectname="MyfirstAnt"default="main"basedir="."><!-- Sets variables which can later be used. --><!-- The value of a property is accessed via ${} --><propertyname="create.dir"location="D:/MyAnt/NewFolder" /><propertyname="delete.dir"location="D:/MyAnt/OldFolder" /> <!-- Deletes oldFolder from the path delete.dir--><targetname="cleanFolder"><deletedir="${delete.dir}" /></target><!-- Creates a newfolder on the path create.dir-…

Setting Apache ANT on Computer (Ant part-2)

Setting up your machine with AntFollow the steps to setup the Ant in your computer.

1. Download the following  files(apache-ant-1.7.0-bin.zip) to your hard drive.

2. Unzip the file to anywhere in your hard drive in any folder.

3. Right click your My Computer icon in the Desktop and choose the properties.

4. In the properties now select the Advanced tab and open Environment Variables button.

5. Click on the New button in the System Variable options and enter the following
Variable name - ANT_HOME
Variable value – The ant path location in your system (for example C:\ant\myant)

6. Click the OK button ans save the setting

7. Set the PATH as below in your system (If you have a PATH variable exists in your system then
append the ANT_HOME to it)
set PATH=%PATH%;%ANT_HOME%\bin


What is Apache Ant ("Another Neat Tool") in java?(ANT Part-1)

Apache Ant ("Another Neat Tool") is a  build tool with special support for the Java programming language however it may be used for regarding everything. Ant is platform-independent. Ant is especially sensible at automating difficult repetitive tasks and so is well matched for automating standardized build processes. Ant accepts directions within the type of XML documents so is extensile and simple to take care of.So you can say it is a xml file you running by the help of Ant.

An ant build file comes within the sort of an XML document, all that's needed may be a straightforward text editor to edit the build file(s). an editor that gives XML syntax lightness is desirable. The ant installation comes with a JAXP-Compliant(Which is XML parser) ,this implies that the installation of AN external XML computer program isn't necessary

For Installation 

1)You will need to download a file apache-ant-1.7.0-bin.zip
2)Extract it 
3)Here you will get "bin" folder
4)In "bin…

20 Facts about google you must know

1) The biggest irony of Larry Page and Sergey Brin’s life is that there original goal for these  two enthusiastic PH.D. Students was to to sell their Google search idea for $1 million to whoever was willing to purchase it. However, luckily for them (and us?), nobody turned up... and In the year 1997, Yahoo rejected an offer to buy Google for $1 million ,whereas Google has grown up to $200 Billion. 

2) Google was originally named Googol but when  Larry Page and Sergey Brin received their first $100,000 paycheck in the name of Google Inc. and they had to run and create a bank account for the name, so that they could cash it. Therefore, the naming ceremony was nothing but an accident.

3)Google's first ever Twitter post was as

For anyone not fluent in binary, here's a hint — it's a well known phrase from the company's homepage. Got it? Yep, it reads: "I'm feeling lucky."

4)Google estimates that the "I'm feeling lucky!" button has cost 
approximately …

Compression of HttpServletRequest and HttpServletResponse by gzip encoding

Description 
This filter is on HTTP headers in a HttpServletRequest, compress data written to the HttpServletResponse, or decompress data read from the request. When supported by the client browser, this can potentially greatly reduce the number of bytes written across the network from and to the client. As a Filter, this class can also be easily added to any J2EE 1.3+ web application.





Installation

1).Add the pjl-comp-filter-XX.jar file containing CompressingFilter to your web application's WEB-INF/lib directory.

2).Add the following entries to your web.xml deployment descriptor:

 <filter>
  <filter-name>CompressingFilter</filter-name>
  <filter-class>com.planetj.servlet.filter.compression.CompressingFilter</filter-class>
 </filter>

 <filter-mapping>
  <filter-name>CompressingFilter</filter-name>
  <url-pattern>/*</url-pattern>
 </filter-mapping>

The below data is of my application where i tested this compression technique…

Example of Garbage collection .

This post is dedicated to explain how Garbage collection works and what can cause memory leaks.
Here we will manually run a small program and will check how memory is allocated to objects and how they it
is collected back when they needed no more.

Lets create a Valueobject which we will access from a class .
below is a Employee Vo which contains name and id of a employees

Lets create a Test class to accesses this Vo .

The above class contains a method m1 and a main method.

When JVM starts it creates to portions to store data
1) heap to keep objects 
2) stack to keep primitive data types and references to heap.Each method will have there own heap

So when we will run the above Test class the memory snap at line number 4 will be

Heap
===================
Empty


Stack
=============
main method
---------------
args:null


so initially heap will be empty and stack will contain the args passed to main method.
Every method has its own stack.
At line number 5 it will store the value of val in stack . it will be in sta…