Category Archives: Java

Using Oracle Dialect in HSQLDB

HSQLDB supports Oracle dialect starting version 2.0 onwards. However, there is not much documentation or examples around this feature. In this post, I will explain the usage of this feature with a simple example. To enable SQL dialect, two steps … Continue reading

Posted in Java, Oracle, Programming | Tagged , , , | Leave a comment

GWT Designer is now free! Yippee!

GWT Designer is a powerful UI development tool for GWT. It is based on the Eclipse framework. Initially a paid tool, it has been re-launched as a free product after Google’s acquisition’s of Instantiations. Read further for details… Continue reading

Posted in GWT, GWT-Ext, HTML, Java | Tagged , , , , | Leave a comment

Java Design Patterns – A Short Writeup

A design pattern is a general, language-independent technique used to solve a class of related problems. A design pattern is a widely accepted solution to a recurring design problem. It is a guideline rather than a specific solution. An idiom, … Continue reading

Posted in Java | Tagged | Leave a comment

Get the Last Day of The Month in Java

Use the getActualMaximum(int field) method of the Calendar class to retrieve the last day of the month. See the below code for usage details. The code retrieves the last date for Feb 2009 as an example. You can modify the … Continue reading

Posted in Java | Tagged , , | 1 Comment

URL Connection via Proxy (the Java 1.5 way)

In enterprises/corporate environments, more often than not, connection to external servers/resources is via a proxy server. While developing applications for such environments, developers need to make sure that their code connects to external sites/resources via the proxy. In this post, … Continue reading

Posted in Java | Tagged , , , , , | 2 Comments

SPRING Quick Tip: Setting application property values dynamically!

Spring provides a very cool feature of passing application property values dynamically using the java -D switch. All you need to do is define the property in the properties file and leave the value part blank. When you run the … Continue reading

Posted in Java, Quick Tips, Spring | Tagged , | Leave a comment

A simple way to list/filter files

Here is a very simple and elegant way to list or filter the files in a given directory. For this use the File.listFiles() method of java.io.File class. The example below deletes all the files that end with the “.tmp” extension. … Continue reading

Posted in Java | Tagged , | Leave a comment

Retrieving the Process ID (PID) in Java

Sometimes it is necessary for a Java application to retrieve it’s own process id. An example of where this could be required is for logging/debugging purposes. Below is a simple “Java way” (there are other ways to discover the process … Continue reading

Posted in Java | Tagged , | Leave a comment

BigDecimal and “java.lang.ArithmeticException: Non-terminating decimal expansion”

In one of my recent projects, I had to use java.math.BigDecimal to divide two values. I had to use BigDecimal instead of double as this was a financial application and required the results to be accurate. However, after running the … Continue reading

Posted in Java | Tagged , | 54 Comments

Retrieving unique items from a List in Java

Here is a very simple and efficient way to retrieve unique items from a java.util.List. All you need to do is put all the items in the java.util.List into a java.util.Set and then create a new java.util.Listfrom the Set. Since … Continue reading

Posted in Java | Tagged , , | 1 Comment