Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 

Comparable Interface in Java

Comparable:- Comparable interface  found in java.lang package and it contains only compareTo() method. It use the single sorting technique to write our own comparison logic and is used to sort the elements on the basis of...

Apache HBase Installation in Standalone mode on Ubuntu

Hi there, Apache HBase can be installed in the following three modes : Standalone mode Pseudo Distributed mode Fully Distributed mode This blog is to setup HBase in standalone mode on your Ubuntu machine without any hassle. You ...

Try block without catch and finally (Try with Resource)

 Try-with-Resource:- Hello Friends, before Java 7, we need to use Catch or finally block with the Try Block in Java.  But In Java 7, we use Try block with resource, through which we can use the Try Block without catch or finally block. ...

File handling basics in Java

Hi there, This blog is to get you familiarize with Java file handling using java.io package. Suppose you need to read the content of your file and need to do operation on that data, in that situation you can opt to use file handling to access ...

Java 8 Date Time Api

Date Time Api in Java 8: Java 8 introduce with new Date Time API. which is much simpler than the old date time api and reduce the overheads faces in the old api  some of the changes are describe below in new date time api. 1. LocalDate/Lo...

How to encrypt password using SHA algorithm ?

Create a strong encrypted password in Java : In almost every application we need to create a strong encrypted password. There are many encryption algorithms to create password. It is good approach to have a strong salt and on the basis of that sa...

Apache Zookeeper installation in Ubuntu for Standalone mode

Hi there, This blog is to help you for Apache Zookeeper installation on your local Ubuntu machine. Apache Zookeeper is used to develop and maintain an open-source server which provides highly reliable distributed coordination.  ...

0/1 Knapsack Solution in Java

Hi, this blog is to help you to know about 0/1 knapsack problem and how to solve it using Java.   Problem Definition Suppose there is a thief who came to steal thing from someone's home. He has a knapsack(shoulder bag) ...

Writing data from MySql table to Excel using Java

Hi readers, If you want to write your MySQL table data to excel sheet. Then by using Apache's POI libraries and MySQL connector you can actually do this. Have a look on the below simple example. It May give you an idea how to proceed....

Word Count program on Hadoop

Hi this blog is to help you to learn that how to run application on Hadoop system. For this we are going to take an example of wordcount program on a data.  So first of all we need our data on which wordcount process has to b...

Hadoop single node cluster setup in Ubuntu

  Hi, this blog is to help you to set up a single node Hadoop environment on your Linux machine. To know about Hadoop follow these links https://en.wikipedia.org/wiki/Apache_Hadoop  http://www.tutorialspoint.com/hadoop...

Quick Sort Implementation in Java

In this blog I am going to explain Quick Sort and also implement it using Java. Quick Sort is an efficient sorting algorithm. It is also known as partition-exchange sort. Quick sort shows an average time complexity&nbs...

Coin exchange problem solution Implementation in Java

Hi, In this blog I tried to provide an efficient solution for a famous coin exchange problem using dynamic problem in bottom up approach whose time complexity is O(mn). Problem Definition In coin exchange problem you can think of ...

Binary Search using Java

Binary search is an efficient linear search algorithm which is also known as half-interval search or logarithmic search. In this algorithm we try to find the target value inside the linear structure. The range should be sorted in order to apply b...

Facebook OAuth Authentication using Java

Hi, This blog is to help you to get Facebook Authentication through OAuth using Java. As Facebook is not offering any SDK for Java clients so with the use of a Json parser we are going to develop a small web application in order to u...

Create a Transformation in Pentaho

Hi Friends. In this blog, I'm going to explain how you can create Transformations in Pentaho Spoon. I shall Extract data from a DBF file, will apply simple (no) Transformation and Load into MySql database. Pentaho comes with different comp...

ThreadGroup Class

ThreadGroup in Java: It represents combination of threads within a group. A thread group can also include other thread groups .With the help of thread group we can easily suspend, resume or interrupt group of threads by a single method call. ...

Upload Multiple Files Jersey REST API

Jersey Rest API also know as JAX-RS "Java API for RESTful Web Services" is a an open source web service framework which is used to develop Java RESTful WEB Services. In this tutorial we will learn to upload multiple file using Jersey REST API. ...

Synchronized block

Synchronized block: Synchronized block is mainly used when there is a sharing of resources and it is used to lock an object for any shared resource so that at a particular time only one object can use that resource. By using synchronized block...

Main Thread in java

Main Thread: When we run a Java program  then main thread begins running immediately. It is created automatically. The main thread is the first as well as last thread in a java program to end. It is the main thread from which other chi...

Return multiple values with different datatype in Java

// A Java program to demonstrate that we can return multiple values of different types by making a class // and returning an object of class. // A class that stores and returns two members of different types class Test { int mul; // To ...

HashSet Class

HashSet Class: It extends AbstractList class and implements List interface. It uses hashing technique to store data. It contains only unique elements. We can use HashSet class by importing java.util package. Example: import java.util.*...

Return multiple values in Java

Java doesn’t support multi-value returns but if all returned elements are of same type then an array can be returned which in turn is returning multiple values. // A Java program to demonstrate that a method // can return multipl...

Simple Spring MVC project

Dear programmers, Please follow the following steps to create a simple Spring MVC project in your favourite IDE.   1. Create a dynamic web application (maven-archetype-webapp) project.   2. Add Spring dependencies : ...

Convert Object to XML using JAXB

Hello Programmers, A number of times, we need to cast our Java object into an XML or vice-versa. The turms are technically know as marshalling and un-marshalling. There are many different Java libraries to do the same in which Castor and ...

LinkedList class

LinkedList class: It provides a linked-list data structure. It uses doubly linked-list to store elements. It extends the AbstractList class and implements List  interface. We can use LinkedList class by importing java.util package. Exa...

NOT LIKE in Hibernate Criteria

The Hibernate Criteria Not like, selects the records that don't match to the matching string given in like parameter. Example: Criteria criteria=session.createCriteria(Tickit.class); //Here you can pass class on which you want to perf...

Formatting date in different format in java

Formatting Date in java: There is a predefined format for dealing with dates in java , but suppose if you want the date in some other format other than the default one then you can use the SimpleDateFormat class of the java.text ...

Getting object values from json data

Getting object values from Json: If you have a data in Json format and you need to retrieve the object values from that day, it can be easily done using Java.   Lets see an example,  If you are using maven add the following ...

Pass Element ID that Triggers `onclick` Event to the Event Handling Function

When we apply onclick event to an element, sometimes we need to pass ID of that element to the event handling function. We can do this by passing id to function as this.id or we can pass the element itself. Example: In the below example I&...

Getting current url in jQuery

Sometimes we need to identify which is the current URL of JSP page to perform some functionality. We can do this very easily by adding the below line in you on load function:   $(function(){ var url = window.location.href; ...

Creating object in Json format using java

Json object: You easily write your object in json format with java . Json format is used because it becomes easy to exchange information in this form. It is easy to understand and easy to write. Lets see an example,  If yo...

Static and Dynamic binding in java

Static Binding: It determines the the type of object at early stage during the compilation itself, i.e. it tells that the object belongs to which class during the compile time of the program.  There is no ambiguity in deciding the type...

Printing current Date in Java

Date Class in java: There is a Date class in java under java.util package which can be used to print the current dates. There can be various ways to print the current date. Lets see with the help of example: import java.util.Date; ...

Convert Xml to Json format using java

Xml to Json conversion: Lets see with the help of example. Following jars are required for conversion: apache-commmons json-lib ezmorph Suppose we have the xml file with name demo.xml with the following data: ...

Setting limit for the no. of words per record in solr while fetching

Fetching records in solr: Once you have finished with indexing in solr, now you can perform search on your records with the help of queries. Go to the url: http://localhost:8983/solr/#/collection/query  There is box with q,&...

Instance Initializer block in java

Instance Initializer Block: There are two types of data members: static and instance data members.  Instance data members are those that belongs to instance of a class. i.e objects. Here comes the role of instance initializer block. It...

Is it possible to run program without main method?

Can we execute a program without using main? Answer is yes, we can run a program without using main with the help of static block. Lets see about static block first. Static Block: It is block which can be used to give initial values to t...

Export from a list containing objects to excel file in java

Suppose you have a list containing objects. You can export it to the excel file.  You will require the following jars for this: xmlbeans-2.3.0.jar poi-3.9-20121203.jar poi-ooxml-3.9-20121203.jar poi-ooxml-schemas-3.9-20121203....

Variable Arguments (Varargs) in Java

Variable Arguments (Varargs) in Java Variable Arguments (Varargs) was introduced in JDK 5. Varargs as the name suggest allows a function to be called with different number of arguments as per the requirement. The syntax of Varargs: ...

Deleting documents in solr collection

Deleting documents: Suppose, you have collection with the name of demo and you have indexed your file in the server in this collection but you want to delete all the documents or some of them, then it is possible by two ways: Deletion by So...

Indexing in Solr Server

Indexing: Solr gives you a quick response and results because of indexing. What does this mean? It means that it searches index instead of the text to retrieve the results for you. In book , you search for the index in the index page of the...

Program to print pascal's triangle using a 2D array in java

Pascal's Triangle:   Program to print Pascal's triangle: import java.io.*; public class Pascal{ public static void main(String []args)throws IOException{ InputStreamReader isr=new InputStreamReader(S...

Solr update using solrTemplate for incremental value

In previous blog Solr Atomic update with incremental popularity, we have updated the solr incremental field using SolrDocument.    Now we will update it through solrTemplate. Here is the sample code: PartialUpdate update =...

How to disable mongoDB java driver logging

Go to mongodb configuration file and add following lines of code. @Configuration public class SpringMongoConfig extends AbstractMongoConfiguration{ static Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME); sta...

Schema configuration in solr

Schema Configuration:   For performing indexing you have to create indexes first in the schema.xml file. This is the file which you have to configure to perform any further operations. It the contains the fields which need...

User-defined Custom Exception in Java.

User-defined Custom Exception in Java Inbuilt class Exception in java can be inherited to create our own exception.   Program creating user defined Exception by extending Exception class: // A Class that represents user-defin...

Creating Collections in Solr

Solr: Apache Solr is a search platform which is developed in Java and can be used for various purposes such as: Using it as a search engine, Can keep your data and use it for querying various things, etc.         &n...

Fetching String of specified length in solr

For fetching a string for a specific value and length, here are 2 ways to do that. First using @Query and another using solr Criteria. In the below code it first searches for the string match and then suing filters we have defined the length o...

Hibernate Encryption using Jasypt

Hi, There are a lot situation when we keep confidential data into our database. When matter of confidentiality comes, encryption comes first in mind. Today, in this article I will try to explain a beautiful technique to do so. This technique d...
prev 1 2 13
Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: