Creating and deploying a Java 8 runtime container image

“This post was originally published on Red Hat Developers. To read the original post, click here.” A Java runtime environment should be able to run compiled source code, whereas a development kit, for example, OpenJDK, would include all the libraries/binaries to compile and run the source code. Essentially the latter is a superset of the […]

Getting started with JBehave in 8 steps.

This post is about JBehave and how to quickly get started with it. If you would like to know about BDD please use the following link. What is Behavioral Driven Development? Today I have used JBehave for the first time. It does have some convincing factors for instance diving requirements into scenarios which map pretty […]

Logging with log4J isDebugEnabled

Alot of times I have seen the questions popping up whether to use isDebugEnabled property or not. Arguably most of the times or rather always about performance. Some of the stuff that I feel important about using it follows.

Calling wsadmin scripts from ant

You can simply add the following to a target. For the following wsadmin should be in your PATH env. < exec dir="." executable="wsadmin.bat" logError="true" failonerror="true" output="wsconfig.out" > < arg line="-lang jython -f ../../createQFactory.py"/ > < /exec > All output will be logged to wsconfig.out

Doing the Locale – Danmark

The following illustrates how to get the Number format working with a danish locale. import java.text.NumberFormat;import java.util.Currency;import java.util.Locale;  public class TestLocale {  public static void main(String args[]){ // Create a Locale for Danmark Locale DANMARK = new Locale("da","DK");  // get the currency instance for this locale. Currency krone = Currency.getInstance(DANMARK);  // Get a Number format for […]

How to read a file from the JAR?

Someone just asked me this question today. And I thought might as well put it down for info. public TestReadFileFromJar() throws FileNotFoundException, IOException { InputStream is = getClass().getResource("txtData/states.properties"); read(is);} In the case above txtData is placed in the jar on the root. Remmember to add the path with the /

Command

By using the command pattern you are seperating the operation from the invoking object. And just because of that it becomes easier to change the command without chagning the caller/s. This means that you could use Command pattern when you might have the following situation You want to parameterize objects to perform an action You […]

Implementing the adapter

Typically when implementing an interface you would have to implement all the methods that exist in that interface. A very good example is the MouseListener in the java Swing. When you need to implement more then one method where as typically you might be catching only one of them. Saying that you would also find […]