Showing posts with label Java. Show all posts
Showing posts with label Java. Show all posts

Wednesday, April 30, 2025

Generate pdf using flying saucer and freemarker

In this article we will go through flying saucer framework and how to use the same to generate pdfs. 

Friday, March 28, 2025

JUnit Interview Questions And Answers

What is JUnit?

JUnit is a widely used testing framework for Java applications. It provides annotations, assertions, and test runners to simplify the process of writing and running unit tests.

Tuesday, March 25, 2025

Spring Web Interview Questions and Answers

  •  What are REST services ?

REST (Representational State Transfer) is an architectural style for building web services that interact using standard HTTP methods (GET, POST, PUT, DELETE, etc.). It relies on stateless communication and uses resource-based URIs (Uniform Resource Identifiers) for addressing.

Friday, March 21, 2025

Spring Boot Interview Questions and Answers

  • What is SpringBoot ? How it is different from Spring framework ?
Spring Boot is an extension of the Spring Framework that simplifies the development of Java applications by providing auto-configuration, an embedded server, and opinionated defaults.

Saturday, November 26, 2022

Spring Boot 3 : New features and migration

Spring Framework 6, released on November 2022, is the major version change and has many high-impacting features, changes and upgrades into the Spring development ecosystem. Similarly, Spring boot 3 is a major version upgrade after 4.5 years of Spring boot 2. Released on November 2022, Spring boot 3 is based on Spring Framework 6 and has lot of changes. In this article we will go through the features and migration approach to Spring boot 3.

Saturday, June 11, 2022

Leetcode : Two Sum

Overview:

Two Sum is a programming problem where you are given an array and a target value and you have to find the indices of the elements in the array that add up to the target value. This is an “easy” level problem in LeetCode. In this article, we will attempt to solve this problem

Monday, September 4, 2017

Spring + Quartz : Scheduler Job with failure recovery

Most IT applications need scheduled processing e.g. maintenance, data flow, clean up etc. which are not initiated by user action. To handle this we can schedule jobs for a particular interval. But what if the job fails or server is down? We do not want to miss the data processing for the interval when job was down or failing. This article explains how to handle such scenario using a Spring and Quartz scheduler.

Sunday, December 25, 2016

MapStruct: Transferring data from one bean to another

Converting data from one form to another is a highly utilized concept in IT industry. MapStruct allows annotation based bean conversion by generating mapper implementation at compile time. This makes sure there is no performance overhead at run-time.

Saturday, July 11, 2015

Jersey : Handle invalid json requests by overriding exception handling

In enterprise applications we usually encounter situations where we get invalid request for our RESTful webservice. The processing fails but client doesn't know the exact cause of problem. In the below article I explain how can we handle invalid request by overriding the exception handling of a Jersey based RESTful webservice.

Saturday, April 18, 2015

Parse json into multiple java pojos using Jackson annotations

Jackson is a suite of data-processing tools for Java (and JVM platform), including the flagship streaming JSON parser / generator library, matching data-binding library (POJOs to and from JSON). In real world programming we will encounter complex cases of JSON to POJO conversion. Here, is one such case where we want to parse a single JSON into multiple java POJOs.

Sunday, April 12, 2015

Generating java files from XSD using Maven and JAXB

Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind XML schemas and Java representations, making it easy for Java developers to incorporate XML data and processing functions in Java applications. As part of this process, JAXB provides methods for unmarshalling (reading) XML instance documents into Java content trees, and then marshalling (writing) Java content trees back into XML instance documents. JAXB also provides a way to generate XML schema from Java objects and vice-versa.
Here we are going to talk about generating java objects from your XSD (XML Schema Definition).

Note : If you are using only Ant for your build, the flow is explained here.

Sunday, March 22, 2015

Configure testing of your web application using Jenkins

Purpose : To demonstrate the automation of testing of a web application after each build.
Assumptions : 1. The application build is already configured on Jenkins. 
                         2. We have a service method that runs all test cases.

I have a web application which is scheduled to build via Jenkins. Now I need to test the application after each build. The following steps can be used to configure test cases :

Friday, October 3, 2014

Overriding equals and hashcode for a POJO

This is an interesting case of programming where you need to compare two POJO objects. You might need to compare standalone objects or you may need to uniquely identify them in a collection. This can be achieved by overriding equals() and hashCode() methods.

Thursday, October 17, 2013

Debugging a java.lang.NoClassDefFoundError

java.lang.NoClassDefFoundError is one of the most common problem while developing Java Enterprise applications. Sometimes debugging a NoClassDefFoundError can be very tedious as you might have to look for missing class dependencies in jar files and may even have to decompile sometimes.

A NoClassDefFoundError is thrown if the Java Virtual Machine or a ClassLoader instance tries to load in the definition of a class (as part of a normal method call or as part of creating a new instance using the new expression) and no definition of the class could be found. The searched-for class definition existed when the currently executing class was compiled, but the definition can no longer be found. In simple words, the class was available at compile time but missing during runtime.

Thursday, October 10, 2013

Generating java files from XSD using Ant and JAXB

Java Architecture for XML Binding (JAXB) provides a fast and convenient way to bind XML schemas and Java representations, making it easy for Java developers to incorporate XML data and processing functions in Java applications. As part of this process, JAXB provides methods for unmarshalling (reading) XML instance documents into Java content trees, and then marshalling (writing) Java content trees back into XML instance documents. JAXB also provides a way to generate XML schema from Java objects and vice-versa.

Here we are going to talk about generating java objects from your XSD (XML Schema Definition).

Note : If you are using Maven for build, then refer this article

Sunday, October 6, 2013

Excel file with Charts in Java using Apache POI

Apache POI is a powerful Java library to work with different Microsoft Office file formats such as Excel, Power point, Visio, MS Word etc. The Apache POI Project's mission is to create and maintain Java APIs for manipulating various file formats based upon the Office Open XML standards (OOXML) and Microsoft's OLE 2 Compound Document format (OLE2). In short, you can read and write MS Excel files using Java. In addition, you can read and write MS Word and MS PowerPoint files using Java. Apache POI is your Java Excel solution (for Excel 97-2008). We have a complete API for porting other OOXML and OLE2 formats and welcome others to participate.

POI has a limitation that we cannot generate charts in Excel using it. So, we have to use a xls template which contains the desired graph and update the row/cells which are used by the graph.