Posted on November 24th, 2015 by Vivek Chaudhary
Sometimes we need to pause the main thread statements until the other thread completes. (Suppose if other thread produces/modifies the data to be used by main thread. If we do not pause the main thread statements in such case then main thread statements may use the data which is not modified/changed yet and an exception […]
Posted on November 24th, 2015 by Pranav Kumar
This tip shows you the way to convert BufferedImage object of java to BitMatrix object in ZXing library. Since in Image processing you must have information about the bits of images so in ZXing library BitMatrix object represents image in bits form. This conversion is the first step during Image processing using ZXing library. First […]
Posted on November 24th, 2015 by Kriti Shrivastava
CXF is a service framework that help to build and develop web services using frontend programming APIs, like JAX-WS. It provides wsdl2java utility to create web service client stub classes using wsdl url. Suppose we have “http://192.168.10.185/DemoService/Service.asmx?WSDL” wsdl url that has operations to add and multiply numbers. To create client stub classes from wsdl2java utility, […]
Posted on November 24th, 2015 by Pranav Kumar
Tip to convert TIF file to pdf using iText library. I am going to explain how we can convert a TIF/TIFF file to PDF document using iText API. Before moving to the main subject of this tip I would like to give a small introduction of iText API. What is iText ?? iText is a […]
Posted on November 24th, 2015 by Java, Variable Argument Method in Java, VarArgs in Java, VarArgs
A method which is able to process variable numbers of parameters is called VarArgs method. Most of us came across a function ‘printf()‘ in ‘C’ which is an example of variable argument type function. VarArgs methods are very useful in terms of application programming. Lets create a VarArgs method using JAVA. public class VarArgsSampleClass { […]
Posted on November 24th, 2015 by Pranav Kumar
This tip is regarding Google Geocode which in itself is a part of Google Map API. Google has released V3 of Google Map API recently. Let me first describe What is Geocoding ?? Geocoding is the process of converting addresses (like “1600 Amphitheatre Parkway, Mountain View, CA”) into geographic coordinates (like latitude 37.423021 and longitude […]
Posted on November 23rd, 2015 by Sukant Shekhar
Challenge: I was given a scenario in which i need to represent a large number by few character it must be hard to break the code. For ex: A 8 digit number into 5-6 character. That too uniquely identified per number (i.e code corresponding to each number should not match the code corresponding to different […]
Posted on November 23rd, 2015 by Debasis Arukh
While writing scripts for a web application in Eclipse, we have go through several elements. Using xpath/css/id etc., we find the element and then we perform some actions on those elements like clicking, sendkeys etc. But later, if the path of a particular element gets changed, the our code won’t work. It will throw error […]
Posted on November 23rd, 2015 by Aditya Moharana
Following steps are to be followed:- 1.Write a Java program that does not contain main method. 2.Complile the java program into .class file(for that you need to install jdk and do the necessary settings) 3.Put the .class file in web_root/WEB-INF/classes(i.e the default class path set in JVM by CF admin). If you want to place […]
Posted on November 23rd, 2015 by Rajashree Mishra
‘Batch Processing’.. The name itself explains that some job is done in a batch (phase wise). Normally when we have requirement of populating data base table from some external source (may be XML or excel sheet), we do loop with the data that to be inserted into specified data base table. If the data is […]
Posted on November 23rd, 2015 by Pranav Kumar
List View is just a way to show your data in a table like structure with as many as rows and columns. In Wicket framework its very easy to use. Now we see how we use it in Wicket Framework:- For using ListView first you will have to create a bean(POJO) file with all fields […]
Posted on November 23rd, 2015 by Prem Chand Mali
Every Java application requires JRE/JVM to run but not every user may have the virtual machine installed on her/his machine. One cannot expect every user to be smart enough to download and install JRE by reading instructions. There are a couple of approaches that a Java developer could take to make sure that her/his application […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
There are a number of ways to read an excelsheet from Java. JExcel is one of them. JExcel API is an opensource Java API which enables developers to read, write and edit excelsheet dynamically in a platform independent way. One good thing about JExcel is that it has no dependencies on any third party libraries. […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
Both the commands (javaw.exe and java.exe) are identical.. The only difference is that java.exe is associated with a console/command prompt, whereas javaw.exe has no command window associated with it. When java.exe command is invoked a Command Prompt’ window is opened automatically. By default, Standard Output and Standard Error streams are directed to the console window. […]
Posted on November 23rd, 2015 by Debabrata Pati
Sometimes we need to show the status message in the RCP application for notifications. The main benefit of showing the status message in RCP application is the fact that its not annoying for the user as no external windows are opened. Below is the code to display status message in RCP. /** * Shows status […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
In Java we can read the environment variables using System.getEnv(). System.getEnv() was introduced in the very begining of Java. deprecated in JDK 1.2 and reinstated in JDK 1.5. we can use the following method to read environment variables. public void readEnvVariables() { Map<String, String> envVariables = System.getenv(); Set stEnvVariables = envVariables.entrySet(); Iterator itrEnvVariables = stEnvVariables.iterator(); […]
Posted on November 23rd, 2015 by Debabrata Pati
Sometimes it’s very necessary to notify/show confirmation the user before exiting the whole application. So, for displaying the confirmation in RCP application we need to either override boolean org.eclipse.ui.application.WorkbenchWindowAdvisor.preWindowShellClose() OR boolean org.eclipse.ui.application.WorkbenchAdvisor.preShutdown() The return value of the above functions determines wheather to close the application or not, which is in default true. Example: public class […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
A new feature introduced in Java5.0 called Static import which allow developers to import static members of a class. In order to access static members, it is necessary to qualify references with the class they came from. System.out.println(“Hello”) Or Java.lang.Math.PI; We can write a program in more readable way by using static import. A static […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
Java has a feature called double brace initialization which allows us to initialize the objects in double brace syntax. For ex. We initialize list in java as below: List<String> states = new ArrayList<String>(); states.add(“Orissa”); states.add(“AP”); states.add(“Maharastra”); But using Double brace initialization we can initialize the list in the following way: List<String> states = new ArrayList<String>() […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
In Java we can take screen shot by using classes and methods defined in java.awt and javax.imageio. In order to take a screen shot first we need to decide the dimension of the screen and create a rectangle with this dimension. There is a class called ToolKit used to take the dimension of the screen. […]
Posted on November 23rd, 2015 by Partho Banerjee
A simple way to get the class structure information of the Class we are using in our application. Step1: Create the Class object of the class we want to explore at run time or the class which is getting added at runtime. Step2: As we are looking for the structure of the class, get all […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
There is a feature in Eclipse called Scrapbook page through which we can execute a snippet of the java code for ex. an expression without creating a new java class. Steps to create a Scrapbook page in eclipse: 1. Select File->New->Other->Java->Java Run/Debug->Scrapbook page 2. Enter a name for the page. 3. Click Finish. This will […]
Posted on November 23rd, 2015 by Priyadarshi Parida
The following tip demonstrates how to read and write data to a file in Java. The code snippet below reads text data from a predefined text file and creates an HTML equivalent.. You can also use it to generate PHP, Javascript and other text-based files.. import java.io.BufferedReader; import java.io.File; import java.io.FileOutputStream; import java.io.FileReader; import java.io.OutputStream; […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
Sometimes we need to send mail from within our application. In java there is an API which supports sending and receiving emails. In order to send mail from a java application we need to add two jars in our application: 1.Mail.jar 2.Activation.jar The following import statements should be include in java code. import javax.mail.*; import […]
Posted on November 23rd, 2015 by Partho Banerjee
This tip describes how text can be converted to image using Java awt.. Step1: Create a String which we will convert to image Step2: Create a BufferedImage Step3: Create get the height and width of the String Step4: call the createGraphics(), which draws the BufferedImage object to Graphics2D object Step6: set the font color, backgroung […]
Posted on November 23rd, 2015 by Partho Banerjee
Configure Tomcat with eclipse IDE. 4 Simple steps to configure Tomcat with the popular eclipse IDE to develop web applications in Java (Tomcat Projects in eclipse). Step 1: Download Tomcat plug-in. Step 2: Close eclipse and place it inside plug-in folder of eclipse. Step 3: open command prompt, go to eclipse home directory and type […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
There are times when we need to calculate the difference between two dates. For example: There was requirement in a project on ticket reservation system to restrict the reservation of ticket to employees who have been hired for at least 6 months. In such cases we need to calculate the difference between two dates.. Below […]
Posted on November 23rd, 2015 by Partho Banerjee
The use of enhanced for loop enables us to loop through a collection member without knowing the size or explicitly iterating elements one by one . This feature is introduced with the Java SE platform in version 5.0. Have a look how it simplifies programming. Old form of looping. for (int i=0; i < […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
System call is a mechanism to execute command line commands from an application. When can we make System calls? From a Java application we can make system calls in such situations as to copy a file/shortcut from one location to another, delete a file, to hide a folder to save it from accidental delete, to […]
Posted on November 23rd, 2015 by Akhil Kumar
From a Java application we can send an email to any recipient on any domain e.g. gmail, yahoomail, etc. The only thing we needed is a valid SMTP . We can also set the validation of the sender in the application during session initialization, since it isdisabled by default. If a user is sending an […]
Posted on November 23rd, 2015 by Akhil Kumar
Java has a great efficient Image handling API in javax.imageio package. Using this package one can do all important image related operations, like Creating Images, Get an ImageData instance from an existing Image, save the image to the local disk etc. To do these operations first we need to scan for the plug-in for the […]
Posted on November 23rd, 2015 by Ashis Mohanty
Basically, we are not directly using string in Java switch case because Java only permit to use Char and Integer variable directly in switch cases. So, in following example I have explained about how to handle String easily in Java switch case. First of all possible string values are declared within a enum then in […]
Posted on November 23rd, 2015 by Debabrata Pati
iText is a library that allows you to generate PDF files on the fly. Please find more details on iText on below link. http://www.lowagie.com/iText/ Here is a code snippet which takes multiple PDFs stream as input and merging them to a new PDF file. The snippet uses iText java library. /**********************************************************/ import java.io.File; import […]
Posted on November 23rd, 2015 by Akhil Kumar
Java developers often need to use graphics and drawing APIs. Due to limited capability of Java SDK, Microsoft’s DirectX API (DirectDraw or ddraw) on Window machine results into drawing problems when using external graphics accelerator card and thus Swing component drawing starts flickering. The work around to this problem is to set ddraw flag off. […]
Posted on November 23rd, 2015 by Partho Banerjee
Sometimes we need to generate reports in excel sheet from our application. The Java Excel API allow us to dynamically create reports in excel. It also allow us to read spread sheets. It supports different formatting of cells and fonts as well as colouring and shading of cells. Below is an example code which creates […]
Posted on November 23rd, 2015 by Prem Mali
Sometimes developers need to store their Java class object in database. This tip demonstrate how we can store object into database and again access the stored Java object. //Creating a simple class. public class SimpleExample implements Serializable{ //Member variable. private int intValue; private String string; public void setIntValue(int intValue){ this.intValue = intValue; } public […]
Posted on November 23rd, 2015 by Milan Chandna
What is Speech Recognition? Speech Recognition means recognizing the speech and converting it into readable form (text). With the help of speech recognition we can take the user voice as input (dynamically), convert it into text and use it to perform various functions in our program. Requirements For speech recognition you need following packages — […]
Posted on November 23rd, 2015 by Tanmayee Sahoo
What is Memory Leak? Memory leak is a bug that mainly occurs when a program does not release the memory it has obtained for temporary use. In other words we can say it is the condition where the available computer memory reduces gradually there by resulting in poor performance. How to determine if Memory Leak […]
Posted on November 23rd, 2015 by Shailendra Singh
In mobile application development, modern platforms such as Android,iPhone, Blackberry etc, provide capability to easily use a Menu Bar but if we were to take a more traditional programming approach, such as J2ME, it becomes difficult as there are no inbuilt Menu Bars. However, we can use a dialog box and give the look and […]
Posted on November 23rd, 2015 by Pranav Kumar
This tip demonstrates how to add a Wicket component to your web page conditionally. To keep it simple I will add a Wicket Label component to a panel if a List is null otherwise not. Here, in my sample code, I am creating a panel named “ExamplePanel” in which I am loading a list of […]
Posted on November 23rd, 2015 by Jyoti Kar
In this tip we will look at what Dependency Injection is and how this design pattern can be helpful. While working on different projects we sometimes come across situations where Java components are tightly coupled. In such cases the component looses its reusability. Using Dependency Injection(DI) we can decouple the components and increase the chance […]
Posted on November 23rd, 2015 by Pranav Kumar
Here I am going to discuss how to implement a link in wicket which opens a desired pdf document in separate popup widow. To implent this link we will go through following steps:- 1. First create Wicket “Resource”(This is a class in Wicket) object and override the “getResourceStream()” method to return a “FileResourceStream” object containing […]
Posted on November 23rd, 2015 by Pranav Kumar
Wicket Framework provides its own implementation class for using AJAX with Web Application. It Provides some normal components like AjaxFallBackLink,AjaxSubmitButton etc with AJAX behavior. Here I am going to discuss how to use the “AbstractDefaultAjaxBehavior” class for targetting any component by clicking that component. I am taking “Label” as a component here for example to […]
Posted on November 23rd, 2015 by Rupal Chatterjee
Home » Tips » Java » Decompile a Java Class This tip demonstrates, step by step, how to reverse engineer a Java class file using a free decompiler program called JAD. The first step would obviously involved downloading a decompiler, which in our case is JAD. http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/JAD.shtml Unpack the zip folder in a particular drive […]
Posted on November 23rd, 2015 by Kaushik Sahoo
Before coming to the topic let us discuss some basics of serialization. What is ‘Serialization’? Serialization is a procees of saving the state of an object by converting it into a stream of bytes. This stream of bytes can be sent over a network, stored in a file or simply can be used to manipulate […]
Posted on November 23rd, 2015 by Rupal Chatterjee
We can access google contacts for particular user credentials very easily now using java. Thanks to Google GDATA api. Google GDATA provides lots of library modules to access google data from client side. Google GDATA api is available for various platforms such as JAVA, .NET, PHP, Python etc. We will be using JAVA for this […]
Posted on November 23rd, 2015 by Kaushik Sahoo
Recently I had a requirement to upload images. The obvious solution was to upload it through form with input type=”file” set method=”post” and enctype=”multipart/form-data” while submitting the form. Sample HTML code: <form action=”testServlet” enctype=”multipart/form-data” method=”post”> <p> Type some text: <input type=”text” name=”textline”> </p> <p> Choose file: <input type=”file” name=”datafile”> </p> <div> <input type=”submit” value=”Submit”> […]
Posted on November 23rd, 2015 by Sudhansu Bal
As a java developer, at times you may face a situation where you need to create a desktop shortcut on Windows, from a java application to launch another jar file. Such a particular and especial situation is when you are creating a desktop application which will be installed through java web start and hence you […]
Posted on November 23rd, 2015 by Rupal Chatterjee
“How do applications like Skype reside in System Tray? Can we do something like this for our application, so that the task tray shows our application icon too? Can we do it in JAVA?” These kinds of questions usually arise in our minds while working. This is what this TIP is all about. FEATURES: 1. […]
Posted on November 23rd, 2015 by Deeptimayi Sahoo
This is an additional information to the tip “decompile a java class” http://www.mindfiresolutions.com/Decompile-a-Java-Class-1219.php We may notice some oddly-named “val$” fields and extra constructor arguments in the decompiled Java code by JAD decomiler.e.g, public void defineAnonymousInnerClass(String name) { new Thread(name) { //extra constructor argument “name” public void run() { System.out.println(this.val$name); //”this.val$” is extra } } .start(); […]
Posted on November 23rd, 2015 by Arup Sahoo
As the Servoy’s code editor supports Javascript and in-line Java, you can use almost all the Javascript keywords with in Servoy. Among the powerful Javascript keywords, “WITH” keyword is used to reduce Object references in your code dramatically. You can also make your code more readable by using WITH. This TIP will explain you the […]
Posted on November 23rd, 2015 by Ajit Singh
So the solution is keep it in your WEB-INF folder so that browser is not able to access it.Simple and steady. That is one part of the story.Beacuse everything cant be kept in the WEB-INF. Other part is – We can also do it by the servlet mapping. Lets take an example and learn it […]
Posted on November 23rd, 2015 by Pranav Kumar
Earlier I had posted a tip regarding detecting the QR in an Image. After detecting we had also fetched the QR Image as BitMatrix object. BitMatrix is just a class in ZXing library which represents an image in 2D matrix of bits form. I think to understand this current tip you must go through a […]
Posted on November 23rd, 2015 by Pranav Kumar
Here I am going to discuss about scanning of QR code in an Image. First I would like to introduce you about QR. What is QR? A QR code (abbreviated from Quick Response code) is a specific matrix barcode (or two-dimensional code) that is readable by dedicated QR barcode readers and camera telephones. The code […]
Posted on November 21st, 2015 by Hare Rai
This demo application will show you how to use google map web service for searching any location. First of all we need to create an Java Web Application with any name, let it be google_app here using Netbeans IDE. It will create an index.js page. The code inside the index.jsp will be similar to this […]
Posted on November 21st, 2015 by Hare Ram Rai
This tip demonstrates how to create a web application in Java. Let us start with creating a webservice with the name web_service_demo. After creating the application , we need to create a package. For creating package right-click on the application project name ,than click on package link. It will show you a pop-up box where […]
Posted on November 21st, 2015 by Prem Mali
Recently we were working on a JAVA Applet for one our clients. Applet was working fine at our end and in client’s testing enviroment but when applet was integrated with live site, problems began. We got an error “Incompatible magic value 218774561 in class file javax/xml/messaging/URLEndpoint”.. Normally this message comes if sandbox (browser) blocks applet […]
Posted on November 21st, 2015 by Ankur Gupta
What is hashmap? A Hashmap is like a foreign language dictionary. You have a key which you use to look up corresponding value.The Hashmap uses a hash of the key for lookups . This is very handy , in the conditions when you have to store a value which has a distinct key and can […]