Category Archives: Java

Java Programing Language

MongoDB: $group aggregation in Java

In this post, we will learn to use a simple way to use MongoDB $group aggregation in Java. First, we will learn to use it in MongoDB itself then try to use that aggregation pipeline in Java. Let’s analyze a MongoDB document in a reports collection which is given below: There are many documents in reports collection. We… Read More »

Difference Between JDK, JRE and JVM

The three components of Java are JDK, JRE, and JVM. In this post, we will learn each of them in detail. JDK JDK stands for Java Development Kit. It consists of all the tools that are needed to develop Java applications. JDK is platform dependent. Hence, we need to download it for each platform. There are different JDK… Read More »

Why Java Is Platform Independent?

Before directly jumping to the reason first, we must understand how Java actually works and what are the component available in Java. So that we can easily understand why Java is platform independent. We all know that Java is a widely used programming language and probably, it is the first choice of large enterprise companies for the last… Read More »

Sort List of Objects in Java

In this short post, we will learn to sort a List of Objects in Java. First, we will create a list of employees and sort employees based on their salary. So that, a user can easily identify who is getting the higher and lower salary. Create an Employee class Create Employee List Printing employees without sorting The output… Read More »

Search In MongoDB Using Java

In this post, we will learn to implement a search query in MongoDB using Java. Most of the applications have search functionality. So, learning to use it will be very useful. 1. Prerequisite MongoDB installed Java driver for MongoDB 2. SQL query example This query fetches all the users whose name has a character ai together. It matches… Read More »

Mapping MongoDB Document to POJO Class in Java

In this post, we will learn to map directly from org.bson.Document object to Java POJO or Java Bean. By default, MongoDB Java Driver maps MongoDB collection document to org.bson.Document object. 1. Employee document sample 2. Insert employee document with bson document We can use org.bson.Document object to insert into database and also fetch data from the database. Let’s… Read More »

MongoCollection in Spring Boot

In this post, we will learn to use a MongoCollection instance for database operations in the Spring Boot application. We all know that we have a spring boot data repository for MongoDB which has an interface MongoRepository and a class MongoTemplate that is the best way in Spring Boot for database operations. Though, Spring Boot provides these options… Read More »

Set Environment Variable in Tomcat

In this post, we will learn to set environment variables in the tomcat configuration file so that when the application loads then it will pick a value automatically from there. Example: Let’s say, we have a Spring Boot application packaged as a war file and we want to deploy it to an external Tomcat server. In this case,… Read More »