Search This Blog

Sunday, 21 September 2014


You can use these expressions in your daily life:

1. Twenty Four Seven (24X7) - (24X7-365)

Meaning: Every Minute Every Day


> I have been working 24/7 on my short film.
          (A kind of an Exaggeration)

> You can access our website 24/7

2. Get the ball rolling

Meaning: Lets start now

> If you don't get the ball rolling on the application soon, you'll miss soon. 

3. Sleep on it


> Before taking a decision, you must sleep on it.

> I will get back to you tomorrow. I will sleep on it.

(means -I will say my decision soon i have think about it once).

4. I am broke

Meaning: I have no Money

5. Like the back of my hand

Meaning: Knows much about something

> I know paris like the back of my hand.

6.  Give me a hand

Meaning: Helping

> would you give me a hand
  (can you help me)

7. In ages

Meaning: for a long time

> I haven't seen him in ages.
  (I haven't seen him for long time)


Meaning: don't want to do any more

> I am sick & tired of doing assignments.

Saturday, 20 September 2014


Usage: - How to make a class whose instance cannot be created by any other class but except itself-(Singleton Design Pattern)

We generally know that constructors in java uses public access modifier. But in fact, constructors can use other modifiers like private


 package com.sample;

 public class MyClass {

   // a zero-argument constructor

    public MyClass(){}


The above MyClass class can be used by other classes by importing it and can get an instance of that class.

What if the constructor uses the a private access modifier like


 public class MyClass {

   // a zero-argument constructor

    private MyClass(){}


In the above case, no other classes can get an instance of the above classes since it is implementing a private constructor.

Let's see one more example:

public class ClientService {

    private static ClientService clientService = new ClientService();

  //private constructor 

    private ClientService() {}

    public static ClientService createInstance() {

        return clientService;


The above example uses a private constructor, where its object is created within itself and used, this scenario restrict others to get an instance.

Private constructors are mainly used in Singleton Design Pattern, where a class can be instantiated only once. In such cases, we can use private constructors.

Tuesday, 16 September 2014


MAVEN is a Java Dependency Management tool. You wonder what is a dependency management tool.

Its Simple...

For instance, if your working on a project which uses many external jar files, which you generally download from the web and then you configure them in the classpath- which is a conventional way of doing.

But if you use maven tool which is basically command line tool(can also be integrated with popular IDEs like NET BEANS & ECLIPSE), you can create a project without this overhead 

Behind the scenes, maven actually works for us a lot to get the required jars from a central repository(collections of jars),  but as a developer only need to do is to supply it the information specifically related to the project you want to create.

We can supply our project information(required jars-simply called as dependencies) through a simple XML file which is called pom.xml

Let us take an example, consider I am developing a JMS application which uses JMS
(Java Messaging Service) API jar file, here for your application this is a dependency, without which you can't create your app. 

And also consider, you are using logging API(requires log4j jar file) in your project for logging purposes, so this is also considered as another dependency.

so we need JMS jar and log4j jar for my project to be completed,so specify them in pom.xml file


<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="" 

        <groupId>....your groupid or your company name..</groupId>
       <artifactId>..your project name...</artifactId>
    <version>..your project build version number---</version>

<!-- Here are your project dependencies-->

           <!-- I can use various maven plugins for different use cases- like reporting
                 ,  mailing, packaging(such jar, war) -->
          <!-- Here I am using a reporting plugin - Maven-Surefire-Report-Plugin
            .This plugin generates a html report showing all my test case failures  
           passed cases & skipped test cases--> 
         <!-- you have use plugins & dependencies according to your project needs--> 


JMS jar details are


log4j jar details are


Terminology :


are tags that maven generally uses to specify the project structure.

groupId is generally a name which represents a company the project belongs to.

artifactId is name of your project

version is the build release version

Plugins are placed under build tag. As aforementioned, you can use any plugins such as war plugin creates a war file for a web application, jar plugin creates a jar file. In the above example, I have defined a surefire-report plug-in , this creates an HTML report for your tests if there are any tests in your project.

Sample Surefire Report 

You can configure your plugins using a <configuration> tag under <plugin> tag.

Let us, you want your surefire-reports, i.e HTML file, you this file to be stored in an outtput directory called newsite. you can configure like this



${basedir}  is the default variable represents the path of your project.

say your project is at c:/documents/MyProject  

so ${basedir} points to this path.

By default, Surefire-report plugin stores its reports in site folder under target.

Maven  has build life cycle phases. During this life cycle phases, it performs various operations. Mostly the build phase names are self-explanatory.

Maven's default build life cycle phases : validate, compile, test, package, integration-test-process, verify, install and deploy.

  • validate - validate the project is correct and all necessary information is available
  • compile - compile the source code of the project
  • test - test the compiled source code using a suitable unit testing framework. These tests should not require the code be packaged or deployed
  • package - take the compiled code and package it in its distributable format, such as a JAR.
  • integration-test - process and deploy the package if necessary into an environment where integration tests can be run
  • verify - run any checks to verify the package is valid and meets quality criteria
  • install - install the package into the local repository, for use as a dependency in other projects locally
  • deploy - done in an integration or release environment, copies the final package to the remote repository for sharing with other developers and projects.

Complete list of Build Phases

<scope> represents this plugin is going to be used in only test phase of the build life cycle.

One of Maven plug in's : maven-compiler-plugin. Its scope is only up to compile build phase. Because it is going to be used only in compiling the classes of your project. so you can specify the <scope>compile</scope> for compiler-plugin.

Important Note: Once maven builds a project - you are able to see a new target folder, where all distributions(war, jar) , surefire reports , and compiled classes are placed in that target folder.

 Until you have pom.xml file in your project folder, you cannot execute your maven goals.

Oh! what are Maven goals? How to execute maven using command line?

Each and every maven build phases binds to some goals:


assume this format for explanation - Build Phase: Goals

compile phase : compiler:compile

During compile phase, a compiler plugin uses these goals to perform its executions.

For example, Maven-compiler-plugin as another goa

compiler: testCompile (here, compiler represents plugin & testCompile is the goal)

Whats the difference between two goals?

Here, the plugin used is same - maven-compiler-plugin. But these two goals: compile & testCompile are executed in two different build phases

Execute maven compile goal  like this
(on command line)

< proj path>$ mvn compiler:compile 

Note: In proj path - you must have pom.xml file.

This only compiles your main source files. (Exclusdes test source files)

Whereas, testCompile goal is bound to test-compile phase 

As I mentioned, test is also a build phase. test-compile is executed just before test build phase. These test classes are excluded during compilation of normal source files.

test phase: surefire-report:report

Here, Build phase is test.  Plugin used here is maven-surefire-report-plugin.


surefire-report represents plugin

report represents goal

Note: This is one of the reporting plugin I have used in test phase. There can be n number of maven reporting plugins. you have decide which to one to choose.
This post will be updated in future also. 
An Updated on 25-Feb-2015