Integrate struts 2 in Liferay portlet

Liferay is a Open Source Content Management System and it’s popularity increasing day by day  but there are no much tutorials on this. Sometimes we find some examples but it may not work exactly the way have been written in the websites. Sometimes the tutorial steps have not been started from the scratch and it results confusion. I am going…

Cucumber Test Framework – Cucumber-JVM with Cucumber-Java + Cucumber-Junit

Introduction Cucumber test framework is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber test framework is written in the Ruby programming language. Cucumber projects are available for other platforms beyond Ruby. Some use Ruby Cucumber with a bridge into the target language (e.g. cuke4php and cuke4lua). Others use the Gherkin parser but implement…

Instantiate Object From A Class Which Contains Private constructor

Private Constructor You probably know that you cannot make any object if the Class contains private constructor but this is not true until a special care is taken to the private constructor. This tutorial shows an example how to create instance using Reflection even if the classes have private constructors. Though if the special care is taken to the private…

How to read input through keyboard in Java

This tutorial shows how to read input from keyword using Java programming language. For example if your database connection string changes then you don’t need to worry because for any database connection string like username and password, this will still work. This is a simple example, you can customize as per your need. You can also apply validation on each…

Verify A String Contains Only Numeric Value Using Java

Introduction The below example shows how to verify that a string contains only numeric value in Java. String may contain float value, double value etc. This example uses regular expression to check a string contains only numeric values. It makes sure that your string should contain only digits and dot(.). You may need sometimes to use string variable for storing…

How to merge Multiple CSV Files into One in Java

Introduction This tutorial shows how to merge multiple csv files into one in Java. You may need to merge multiple csv files into one in some situations for your business requirements. Suppose there are n number of csv files and each csv file is having different number of headers, so this example will show you how to merge multiple csv…

Marker Interface example in Java

Introduction The marker interface pattern is a design pattern that provide run-time type information about objects. It provides a means to associate metadata with a class when there is no explicit support for such metadata. The marker interface in Java does not have any method inside it, in other words, a marker interface in Java is an empty interface. Marker…

Externalization example in Java

The Externalizable interface provides the necessary means for implementing a custom serialization mechanism. Implementing the Externalizable interface means that we must override writeExternal() and readExternal() methods. These methods will be called when you serialize or deserialize a particular instance or object. The difference between Serialization and Externalization is that when we implement the Serializable interface we do not need to…

Simple Log4j Configuration in Java

Introduction We will see here an example on simple log4j configuration in Java. The purpose of inserting log statements into the code is a low-tech method for debugging it. It may also be the only way because debuggers are not always available or applicable. This is often the case for distributed applications.

How ThreadLocal Works In Java

Introduction Here you will see how ThreadLocal works in Java. Java ThreadLocal class is used to create thread-local variables. The thread-local variable can be read and written by the same thread only. In multi-threaded environments all threads of an Object share their variables, so if the variable is not thread safe, then an inconsistent state of the variable occurs. Therefore…