Windows BAT file to execute runnable jar file and checks if it is already running Suppose you have a Java Desktop application, for instance, a SWING application. How would you like to present the runnable JAR file to the client? Am pretty sure many would prefer the BAT script file in case the target machine is WINDOWS based and the ... Read More »
Java Core
Maven- Creating a Jar together with its dependency Jars into a single executable Jar file
Maven- Creating a Jar together with its dependency Jars into a single executable Jar file Suppose your boss comes and ask you to create a standalone JAVA application. Assuming you being a MAVEN lover, you created a JAVA application using MAVEN dependency management tool. Now suppose you have some MAVEN dependencies that are needed by your JAVA application. Since, it’s ... Read More »
Twitter search API- Get tweets and tweets count of hashtag using JAVA twitter client Twitter4j
Twitter search API- Get tweets and tweets count of hashtag using Twitter4j JAVA I have searched many resources on internet for how to obtain tweets count for a particular hashtag. To may observation there is no API exposed by Twitter for getting counts data for a hashtag.But there is a search tweets API that provides tweets data(including retweets) for a ... Read More »
Potential security hole- Final field containing a reference to a mutable object
Potential security hole- Final field containing a reference to a mutable object As a thumb rule, instance fields should never be public. If an instance field is non-final, or is a final reference to a mutable object, then by making the field public, we give up the ability to limit the values that can be stored in the field. So ... Read More »
Consider implementating compareTo and equals method
Consider implementating compareTo and equals method Unlike the other methods the compareTo method is not declared in Object. Rather, it is the sole method in the Comparable interface. It is similar in character to Object’s equals method, except that it permits order comparisons in addition to simple equality comparisons, and it is generic. By implementing Comparable, a class indicates that ... Read More »
What is Quick sort and usage of Quick sort in JAVA Arrays.sort method
What is Quick sort and usage of Quick sort in JAVA Arrays.sort method As per JDK-8 Arrays.sort method uses Quick sort algorithm for sorting of data in ascending/descending order. So this post is for persons who wants to know, how does Quick sort works. In JAVA world quick sorting is used to sort an array. In our example we will ... Read More »
What is Merge sort and usage of Merge sort in JAVA Collections.sort method
What is Merge sort and usage of Merge sort in JAVA Collections.sort method Manipulating data in a faster and efficient way has always been the fantasy of every language and JAVA is no untouchable in this case. As per JDK-8 Collections.sort method uses Merge sort algorithm for sorting of data in ascending/descending order. So, what is Merge sort? Well, if ... Read More »
Which is better option: Java clone or Copy constructors or Copy static factory?
Which is better option: Java clone or Copy constructors or Copy static factory? The Cloneable interface was intended for objects to advertise that they permit cloning. Unfortunately it fails to serve this purpose. It’s primary flaw is that it lacks a clone method, and Object’s clone method is protected. So what does Cloneable do, given that it contains no methods? ... Read More »
How to create an asynchronous HTTP call in JAVA
This tutorial explains How to create an asynchronous HTTP call in JAVA. What is asynchronous HTTP call? Asynchronous HTTP Request call allows us to process an HTTP call using non-blocking I/O in a separate thread. The main use for Asynchronous HTTP call is where the client is calling a server with a delayed response, which may result in the client ... Read More »
SSL handshake alert: unrecognized_name Exception
This tutorial explains how to handle SSL handshake alert: unrecognized_name exception while calling an URL over SSL/https . When I tried to connect a web-server over SSL, I was getting the below error continuously. This happened with JDK1.7 and above. Below is the sample Java programme which I was running. Issue : Exception I was getting - Solution : After ... Read More »
Jkoder.com Tutorials, Tips and interview questions for Java, J2EE, Android, Spring, Hibernate, Javascript and other languages for software developers