KOTLIN / NOTES</>↗Kotlin12 May 2018
In Kotlin, the HelloWorld.kt program can be written as a simple function like the following snippet. fun main(args: Array<String>) { println("Hello, World!") } From this little code snippet we can learn the following features of the Kotlin programming language: Kotlin program saved in a file with .kt extension. The fun keyword to declare a function […]
OS X / NOTES</>↗OS X13 Nov 2017
In this post you will learn how to set the default JAVA_HOME in Mac OS X when you have more than one JDK installed in your computer. First you need to run /usr/libexec/java_home -V command to get the list of installed JDK. The command will print out something like the following depending on the available […]
TOOLS / NOTES</>↗Tools16 Oct 2017
If you want to run a sudo command without being prompted to input the password you can do the following command. echo password | sudo -S rm -rf /opt/jetty/ In the command above we are trying to remove the /opt/jetty directory using the rm -rf command. The -S (stdin) option allow the sudo command to […]
JACKSON / NOTES</>↗Jackson14 Feb 2017
The following example demonstrates how to pretty print the JSON string produces by Jackson library. To produce well formatted JSON string we create the ObjectMapper instance and enable the SerializationFeature.INDENT_OUTPUT feature. To enable this feature we need to call the enable() method of the ObjectMapper and provide the feature to be enabled. ObjectMapper mapper = […]
JAVA 8 / NOTES</>↗Java 813 Feb 2017
The following code snippet demonstrate how to convert java.time.LocalDate to java.util.Date and vice versa. In the first part of the code snippet we convert LocalDate to Date and back to LocalDate object. On the second part we convert LocalDateTime to Date and back to LocalDateTime object. package org.kodejava.datetime; import java.time.*; import java.util.Date; public class LocalDateToDate […]
JACKSON / NOTES</>↗Jackson13 Feb 2017
We have a Recording class which has a Java 8 java.time.LocalDate property. We need to deserialize and serialize this property from and to JSON string. To do this we can use the @JsonDeserialize and @JsonSerialize annotations to annotate the LocalDate property of the Recording class. @JsonDeserialize(using = LocalDateDeserializer.class) @JsonSerialize(using = LocalDateSerializer.class) private LocalDate releaseDate; To […]