Category: Java

json tutorials

Serialize and Deserialize Primitives with GSON

GSON can serialize or deserialize any primitive type into JSON representation. Below you can find a list of all primitive types. First you can find how to serialize primitive types into their JSON representation...
java tutorials

Detect OS Name and Version Java

Java is Platform independent and can run everywhere. Knowing this, it can be worth knowing in what operation system the application is running. To detect the current operation system, you can use the OSInfo...
java tutorials

Get Current Working Directory in Java

You can retrieve the current working directory by calling System.getProperty(“user.dir”). This returns the root folder of your current java project. Example package com.memorynotfound.file; import java.io.File; public class FindCurrentWorkingDirectory { public static void main(String… args){...
java tutorials

Find User Home Directory in Java

The System class maintains a Properties object that describes the configuration of the current working environment. Within these properties there exists one that identifies the users home directory. In most scenarios this will work,...
json tutorials

GSON Versioning Support with @Since Annotation

GSON introduced the @Since annotation to support multiple versions of the same object. We can use this annotation on Classes and Fields. In order to enable this feature we need to register a version...
jsf tutorials

JSF Pass Parameters in Localized Error Messages

When an error occurs in the backend and you need to inform the user what happened, you can display an appropriate error message. JSF provides an easy utility to display these messages. You can...
jsf tutorials

JSF Component listener with @ListenerFor

This tutorial shows how to add a listener to a component using the @ListenerFor and @ListenersFor annotation. The @ListenerFor annotation allows a component to subscribe to particular events with the component itself being the...
jsf tutorials

JSF SystemEventListener Example

This tutorial shows you how to use the JSF SystemEventListener. A SystemEventListener can listen to many registered system events. Those system events can be fired by many kinds of sources (components). We can specify...
jsf tutorials

Debug JSF Lifecycle with Custom DebugPhaseListener

This tutorial shows how to debug JSF Lifecycle with a custom DebugPhaseListener. The first place that most developers check for information about where issues are occurring is the application logs. As you are debugging...