Category Archives: Code Snippets

Short and usefull code snippets and tutorials used in day-to-day programing

Eclipse RCP – Simple Logging mechanism

This is a short snippet to solve you logging needs in Eclipse RCP application by using build in logging functionality. I have created 3 simple static utility methods but you can create your LogUtil utility class as you wish based on this example: import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; public class LogUtil {     public static […]

Read More →

Java EE 6 – JSF 2.0 Internationalization with session scoped language switcher bean

Today I will present a short tutorial on how to implement internationalization feature in your JSF 2.0 web application. This tutorial is based on the previous one called Java EE 6 – Getting Started (maven, CDI and persistence) ready project. We will continue from that point and add simple i18n feature with language switching capabilities. […]

Read More →

Java EE 6 – Getting Started (maven, CDI and persistence) ready project

This short tutorial describes how to get started easily and quickly with Java EE 6 development. For the purpose of this tutorial you would need to have installed the following tools: 1. Maven 3 2. JBoss AS 6.0 3. Eclipse (I will use Helios release) 4. Eclipse m2eclipse plugin (for managing Maven based projects) If […]

Read More →

Getting started with Drools Flow

Today I will present my latest discovery called JBoss Drools and Drools Flow in particular. I am completely new to the drools framework and because I couldn’t find myself a quick and simple intro to the framework I will post it myself. Presented example is completely useless from the business perspective and it doesn’t describe […]

Read More →

Android Series: Display device CPU and Memory info

Today I will post a short snippet on how to display cpu and memory info of our andorid device. The program uses external utilities to get the device info by calling cat on ‘/proc/meminfo’ and ‘/proc/cpuinfo’. The activity displaying the data from the ‘cat’ output is displayed in a TextView contained withing ‘ScrollView’. This is […]

Read More →

Android Series: Download files with Progress Dialog

Today, I will present a short tutorial on how to download files in android displaying at the same time download progress based on the bytes downloaded. For the purpose of this tutorial we will use build in AsyncTask mechanism together with ProgressDialog class. The whole application consists of one activity displaying a ‘Start Download’ button. […]

Read More →

Design Patterns Series – Part Five: Adapter pattern

According to wikipedia: In computer programming, the adapter pattern (often referred to as the wrapper pattern or simply a wrapper) is a design pattern that translates one interface for a class into a compatible interface. The adapter pattern is commonly used when there is a need to access an object through the interface which doesn’t […]

Read More →

Android Series: Creating custom dialogs

Short tutorial on how to implement custom dialogs on the Android platform

Read More →

Design Pattern Series – Part Four: Observer pattern

Today I’m adding another important design pattern to the toolbox. Observer Pattern is commonly used and quite powerful. The Observer Pattern defines one to many dependency between objects so that when one object changes state, all of it dependents are notified and updated. We can create a class structure for the pattern ourselves from scratch […]

Read More →

The Biggest Java WTF

Today one of my co-workers send me the following link. As I couldn’t believe my eyes, I have tested it myself. WTF? package wtfjava; /**  * This program really HANGS!!!!  * @author kris  */ public class Main {     /**      * @param args the command line arguments      */     […]

Read More →