Wednesday, April 26, 2023

10 Reasons to learn Node.js for Web Developers in 2024

In full-stack development, backend development is often considered more complicated and tougher. It's not easy to be a backend developer. Backend is considered the brain of the application and if anything goes wrong here, the whole application can collapse. So the backend should be solid and people working on it should be skilled. Backend development has advanced a lot in the last two decades. For years, backend development was dominated by PHP. But, when JavaScript was taken out of the browser, it changed everything. The emergence of Node.js in 2008 changed everything for the backend development community. JavaScript was no more a client-side language. Now, it could be used on the server-side too. Thus making it a full-stack programming language.

React Native vs Flutter? Which is better to learn for App Development in 2024?

Hello guys, if you are wondering whether to learn Flutter or React Native for App Development in 2024 then you have come to the right place. Earlier, I have shred best courses to learn Flutter and React Native and in this article, I will share my thoughts on which one is better suited for App development in 2024 and which mobile app development framework beginner should learn in 2024. In the recent decade, the mobile application community has grown tremendously. The total number of applications on the play store surpassed one million in the year 2013 and by mid-2020, it was estimated that there are more than 2.8 million applications on the google play store. 

Angular vs React vs Vue.js ? Which is better to learn web development in 2024?

JavaScript web frameworks are important parts of modern web development. Several JavaScript web framework and libraries are active today. If you plan to become a web developer, you may encounter these web frameworks. A web developer, especially a front-end web developer should be skilled in at least one of these frameworks. Angular and React are the two most popular web frameworks and libraries today. Vue.js is the rising star. In this article, we will compare these three frameworks on different parameters like Community support, Performance, ease of Learning, and jobs to find out which frontend development framework between Angular, React.js and Vue.js you should learn in 2024. 

8 Examples of Primitive Data Types In Java (int, long, boolean, float, double, byte, char, and short)

Hello guys, Data types are first few things you should learn when you start learning a programming language and when it comes to learn Java, there are 8 primitive data types which you should know. These are divided into three categories, numeric, text, and boolean values. Numeric data types can be further divided into two like natural numbers and floating pointing numbers. But, Before we get to a list of the 10 examples of primitive data types in Java, let me tell you a little bit more about what the primitive data types are.  There are essentially 8 primitive data types in Java. They are int, byte, short, long, float, double, boolean, and char. The primitive data types are not considered objects and represent raw values. These primitive data types are also stored directly on the stack.

10 points on TCP/IP Protocol, Java Programmers should Know

TCP/IP is one of the most important protocol as its backbone of HTTP, internet and most of the communication happens today. It's also important from technical interview perspective, you might have already seen difference between TCP and UDP multiple time during interviews ( I have seen). I believe every programmer, not just Java developer should know what is TCP/IP protocol? How it works and the below points I am going to mention. These are basic points and most of you already know but during Interview I have found many developers who doesn't really know what TCP/IP offers and how it works and what are the pros and cons of TCP/IP protocol. That's where, I think this article will help you. Anyway, let's jump into technical details now. 

How to write to a File with try-with-resource in Java? Example Tutorial

Hello Java programmers and all people learning Java, if you are familiar with try-wit-resource statement then you know that its a great language functionality and tool to open files, sockets, streams, and network connections or any resource which are require closing. Before try-with-resource was introduce in Java 7, Java developers have to manually write try catch finally block to close the connections for both success and failure cases to prevent resource leak but it was also tricky and many programmer make mistakes which actually resulted in resource leaks. One common example of that is running out of file descriptors which is used for both opening file and socket in Java.  

Monday, April 24, 2023

What is try with resource in Java? Example tutorial

In Java we normally use resources like file, network connection, socket connection, database connection etc ,dealing with resources is not a difficult task but what if after using the resources programmers forget to close the resources. As we know in Java everything is Object so if we forget to close or shut down the resource its responsibility of GC that will recollect it when its no longer used but we can reduce resource exhaustion by explicitly closing the resources as soon we done with our job with the resources. Some resources like database connection are very precious and would surely run out of resources if waited for finalization. Many database servers only accept a certain number of connections so if forget to close properly will create problem.

How to get the first and last item in an array in Java? Example Tutorial

Firstly, before going about finding the first and the last item of an array in java. We need to fully understand what an array is and how it works. What then is an Array? An array is a data structure in java that holds values of the same type with its length specified right from creation time. Think of a container, like a crate of eggs or coke. What I am trying to say is that when you are creating your array, the items coming in must be the same as you have specified as length and you must specify how many items are coming. If you have stated that the items coming are integers, so it is and no other data type (e.g string, char e.t.c) can be there and vice versa. Or you can say an array is a collection of similar type of elements which has contiguous memory location.

Difference between array and Hashtable or HashMap in Java

A couple of days back someone asked me about the difference between an array and a hashtable, though this is a generic data structure and programming question, I'll answer it from both a general programming perspective as well on Java perspective where Hashtable is not just a data structure but also a class from Java Collection API. Even though both array and hashtable data structure are intended for fast search i.e. constant time search operation also known as O(1) search, the fundamental difference between them is that array require an index while hash table requires a key which could be another object. 

Anonymous Class to Lambda Expression in Java 8? Example Tutorial

Hello guys, you may be thinking why I am talking about Anonymous class now when many Java programmers have already switched to Java 8 and many have already moved on from Anonymous class to Lambda expression in? Well, I am doing it because I am seeing many Java programmers who find it difficult to write and read code using lambda expression in new Java 8 way. It's also my own experience that if you know the problem first, you can better understand the solution (lambda expression). Some of you might remember, the opening scene of MI 2 (Mission Impossible 2), when Nekhorovich says to Dimitri that "Every search for a hero must begin with something that every hero requires, a villain. Therefore, in our search for a hero, Belairiform, we created the monster, Chimera"

Java FileReader + BufferedReader Example

There are multiple ways to read a file in Java e.g. you can use a Scanner as we have seen in the last example, or you can use the BufferedReader class. The advantage of using a BufferedReader to read a text file is speed. It allows faster reading because of internal buffering provided by BufferedReader. Other Reader classes like FileReader access the file or disk every time you call the read() method but BufferedReader keeps 8KB worth of data in its internal buffer which you can read it without accessing the file multiple times. It's loaded when you access the file the first time for a subsequent read.

10 Examples of print(), println() and prinf() methods In Java - PrintStream

Hello guys, if you are working in Java or just started with Java then you have must come across statements like System.out.println("Hello world") to print something on console or command prompt. This is actually the first statement I wrote in Java when I started programming and at that time I didn't realize how it work and what is System and PrintStream class and what is out here but now I know and I am going to explain all this to you in this article, along with PrintStream class and its various print methods like print(), println() and particularly printf() to print various objects in Java. But,   Before we get to the 10 examples of Printstream printf() in Java, let me tell you a little bit more about what exactly Printstream is. 

Chain of Responsibility Pattern in Java? Example Tutorial

Hello guys, if you have been doing Java development then you must have come across design pattern, tried and tested solution of common software problem. In the past, we have looked at several popular Object Oriented Design Patterns in Java like Adapter, Decorator, State, Strategy, Template, Composite, Command, Observer, Factory, Builder, Visitor etc, and today I am going to talk about Chain of Responsibility design pattern in Java. The Chained or Chain of Responsibility Pattern is a design pattern that allows a request to be passed along a chain of objects until it is handled by one of the objects in the chain. This pattern is helpful for situations where it is not known in advance which object in the chain should handle the request, or where the request needs to be handled by multiple objects in the chain.

3 ways to convert String to JSON object in Java? Examples

It's very common nowadays to receive JSON String from a Java web service instead of XML, but unfortunately, JDK doesn't yet support conversion between JSON String to JSON object. Keeping JSON as String always is not a good option because you cannot operate on it easily, you need to convert it into a JSON object before you do anything else e.g. retrieve any field or set different values. Fortunately, there are many open-source libraries which allows you to create JSON object from JSON formatted String like Gson from Google, Jackson, and json-simple. In this tutorial, you will learn how to use these 3 main libraries to do this conversion with step-by-step examples.

Sunday, April 23, 2023

Top 10 Projects to Learn Front-End Web Development

Hello guys, If you are looking for ways to learn Front-End Web Development, you have come to the right place because all of what you want is right here. You just have to keenly go through this article till the end and you will get what you need.  Front-end web development is a popular field that involves creating the user interface and experience of websites and web applications. It is an ever-evolving field that requires developers to stay up-to-date with the latest tools, technologies, and trends. One of the best ways to learn front-end web development is through hands-on projects. In this article, we will explore the top 10 projects that can help you learn front-end web development and enhance your skills in HTML, CSS, JavaScript, and other related technologies. 

How to use @JsonCreator and @JsonPropertOrder Jackson JN Annotation in Java? Examples

Hello guys, if you are dealing with JSON in Java then you may have come across Jackson, one of the popular JSON library in Java. Jackson provides many cool annotations to serialize and de-serialize JSON to Java object and vice-versa. Earlier, I have showed you 3 ways to convert JSON to Java object and 10 free Jon Tools for programmers and in this article, we will deep dive into two popular Jackson annotations @JsonCreator, @JsonProperty, and @JsonProperOrder. But, Before I tach you exactly how you can use the @JsonCreator annotation, let me briefly tell you a bit more about what Java really is.

Top 5 Functional Interface Every Java Developer Should Learn

Hello guys, functional interface in Java are an important concept but not many developer pay enough attention to them. They learn lambda and method reference but the functional interface from java.util.function package. While its not really possible to learn all the functional interfaces on that package but you can learn a few more commonly used ones like Predicate, Supplier, Consumer etc and that's what you will learn in this article.  But, before we get to the top 5 functional interfaces that every Java developer should learn, let me tell you a bit about what Java really is. 

Difference between Class and Object in Java? Example

Class and Object are two pillars of Java and any Object oriented programming language. There are multiple ways you can describe Class in Java, I will start with how I remember class from my college Days. That time, I used to remember that "A class is a blueprint to create object" and that's how I answer during viva or exam. While I know what is a blueprint, I didn't really understand what a class can do. Later, when I started coding, I learned about data types like int data type to hold integer values. String data type to hold text values.  

How to convert List Of of Object to Map of Object (key, value) In Java? Example Tutorial

Hello guys, if you have a list of object and you want to conver into Map of object or key value pair then you can use different ways like looping over list and then adding values to map, or you can use Collectors.toMap() by using Stream API, You can even use flatMap() function if you want to convert list of one type of object to Map of another type of object. All this is possible and I will show you code example of how to do that in this article, But, before we get into the process of how you can convert a list of one object to another in Java, let me tell you a bit more about what Java really is. 

What is WeakHashMap in Java? HashMap vs WeakHashMap Example Tutorial

Hello friends, we are here today again on our journey to Java. I hope everyone is fine and ready to board our train of knowledge. Today we are gonna learn something very interesting and very exciting. Today's topic will definitely be very useful in coding and programming. This topic would surely decrease your time complexity, and space requirements for any task very significantly :p So what's the wait? Let's start!

JDBC - Difference between PreparedStatement and Statement in Java? Answer

If you have worked with database interfacing with Java using JDBC API then you may know that the JDBC API provides three types of Statements for wrapping an SQL query and sending it for execution to the database, they are aptly named as Statement, PreparedStatement, and CallableStatement. First, a Statement is used to execute normal SQL queries like select count(*) from Courses. You can also use it to execute DDL, DML, and DCL SQL statements. 

Can you make a class static in Java? Example

This is one of the tricky questions in Java because there is no straightforward. Yes and No answer here. You cannot make a top-level class static in Java, but Yes, you can make a nested class static in Java. In fact, it is even advised (see Effective Java) to prefer a nested static class in Java to normal inner classes. Now, the question comes what is a top-level class, and what is a nested class in Java? Well, you can declare multiple classes in a single Java source file. A class is said to be the top-level if it is not inside any other class, and a class that is inside another class is known as a nested class. You can create a nested class inside another top-level or another nested class in Java. This is the class that can be static in Java.

Difference between Fixed and Cached Thread pool in Java Executor Famework

There are mainly two types of thread pools provided by Javas' Executor framework, one is fixed thread pool, which starts with fixed number of threads and other is cached thread pool which creates more threads if initial number of thread is not able to do the job. The newCachedThreadPool() method is used to create a cached pool, while newFixedThreadPool() is used to construct a thread of fixed size. Cached thread pool executes each task as soon as they are submitted, using an existing thread if its idle or creating new threads otherwise, while in case of fixed thread pool, if more tasks are submitted then idle threads then those task are put into a queue and later executed once any other task has finished.

Difference in Method Overloading, Overriding, Hiding, Shadowing and Obscuring in Java and Object-Oriented Programming?

Hello guys, today, I am going to explain a couple of fundamental object-oriented programming concepts in Java, like Overloading, Overriding, Hiding, Shadowing, and Obscuring. The first two are used in the context of a method in Java while the last three are used in the context of variables in Java. Two methods with the same name and same class but the different signature is known as overloading and the method is known as an overloaded method while a method with the same name and same signature but in parent and child class is known as overriding. On the other hand,  Hiding is related to overriding since the static and private method cannot be overridden, if you declare such methods with the same name and signature in parent and child class then the method in the child class will hide the method in the parent class.

Difference Between Iterator and Enumeration In Java

What is the difference between Iterator and Enumeration in Java is one of the oldest core Java Interview Questions. While I haven't seen this question for a long time, I still think its an important concept to know and remember for Java developers, especially those who are tasked to work in existing project which may be using Enumeration. The Iterator and Enumeration are two interfaces in Java and used for traversing in java collection we found these two interface in the java.util package .whenever we go for an interview if interviewer goes in collection topic he will often ask the difference between this two .so let's see one by one difference between this two and compare which is used when and which one is better.

Saturday, April 22, 2023

Top 20 Docker Interview Questions Answers Java Developers and DevOps

Hello guys, if you are preparing for a Java developer interview, a DevOps engineer interview or any software developer interview, one tool which should pay most attention is Docker. It's a container tool which allows you to package and deploy your application in cloud. Docker has many benefits as it not only standardized packaging and deployment but works nicely with Kubernetes which takes the scalability and automatic restart of your application. These are just a couple of benefits but because of all these, Docker has become an essential tool for every programmer and developer and that's why they are also quite important for interviews. 

Top 30 Gradle Interview Questions Answers for Experienced Java Developers

Hello guys, if you are preparing for Java or Kotlin developer interview where Gradle skills are needed then you should prepare for Gradle related questions. I have seen many interviewer asking Maven and Gradle related questions during interviews and many Java developer don't prepare them. But, considering you are looking for Gradle questions I think you are one step ahead of them and If you are looking for Gradle interview questions then you have come to the right place. Earlier, I have shared Maven Interview Questions and in this article, I am going to share Gradle interview questions for Java and Kotlin developers. 

Difference between Proxy and Decorator Pattern in Java

Hello guys, if you have gone through a couple of Java Developer interview then you may seen this question about Proxy and Decorator Pattern in Java. Earlier, I have share 18 Design Pattern questions and today, I am going to answer this tricky design pattern questions from Java interviews. I was first asked about difference between Proxy and Design Pattern in Java a couple of years back when I was interviewing for Senior Java developer interview on a big investment Bank and I wasn't able to impress interviewer with my answer, so I decided to learn more and this article is the result of that research. Though both Proxy and Decorator pattern looks very similar to each other structurally, there are some key differences between them like what problem them solve and how they are used in Java application. 

[Solved] How to find the Longest common prefix in Array of String in Java? Example Tutorial

Hello guys, If you are preparing for technical interviews and wondering how to solve the longest common prefix in a given array of String problems in Java then you have come to the right place. Earlier, I have shared 21 String programming problems and one of them was this one. In this article, I am going to show you how to solve this frequently asked coding problem from Java Interviews. It's one of the difficult coding problems and not every programmer I have interviewed has solved this, only a few can solve this so preparing for this one can definitely improve your chances and give you a competitive edge over other candidates.

10 examples of crontab commands in Linux

Hello guys, if you are working in Linux or UNIX environment and scheduled any job or script to run at a particular time at everyday like a script to archive log files at midnight or a script to restart your app on Monday morning then you must have come across crontab command in Linux. While there are many solution to schedule jobs in enterprise application like Control M from Bmc Software and AutoSys but the crontab command provides the easiest way to schedule any script in Linux, as you don't need any third party software for scheduling. It's also quite popular, so much so that all the jobs scheduled by crontab is called cron jobs, and that's why I think every developer should know about crontab command and how to use it. 

Friday, April 21, 2023

Difference between child and descendent selectors in jQuery in CSS?

Main difference between descendant and child selector in jQuery or CSS is that descendant selector selects all dom elements whether they are its direct children or not, on the other hand child selector only select direct childrens. Its very easy to understand if you know meaning of descendant and child. For example, my daughter is both my child and descendant but my granddaughter is not my child but descendant. Same definition work in both CSS and jQuery world Since jQUery got his selector from CSS itself, any difference between descendant and child selector which is valid for CSS is also valid for jQuery, unless otherwise stated. Now, lets understand this in terms of DOM elements

Top 21 Git Interview Questions and Answers for Programmers and DevOps

Hello guys, if you are preparing for Software developer interview then you should prepare for Git, one of the essential and most popular version control and source control tool in Software industry. Almost every company, both big and small are now using Git to store their source code and conduct code reviews, yes the code review is one of the main reason many organization shifted to Git. Both Github and BitBucket provides in-built code review features which also promote good software development practices. 

Thursday, April 20, 2023

5 Difference between Iterator and ListIterator in Java?

The Iterator is the standard way to traverse a collection in Java. You can use Iterator to traverse a List, Set, Map, Stack, Queue, or any Collection, but you might not know that there is another way to traverse over List in Java? Yes, it's called the ListIterator. There are many differences between Iterator and ListIterator in Java, but the most significant of them is that Iterator only allows you to traverse in one direction, I mean forward, you have just got a next() method to get the next element, there is no previous() method to get the previous element. 

HelloWorld Program in Java with Example

First of all, welcome to the exciting world of Java programming. If you are ready to write your first Java program i.e. HelloWorld in Java, it means you already crossed major hurdles to start Java programming, in terms of installing JDK and setting PATH for Java. If you haven't done so then you can follow those tutorials to install JDK in Windows 7 and 8 and setting PATH for Java. Before we start writing HelloWorld in Java, few notes about editors. Many Java beginners insist or try to use Eclipse or Netbeans IDE from the very start of the first program, which is not a good idea. 

Difference between GenericServlet vs HttpServlet in Servlet JSP - J2EE question

Difference between GenericServlet and HttpServlet is one of the classic Servlet Interview Question, asked on many Servlet and JSP Interviews on 2 to 4 years experience developers. Since both GenericServlet and HttpServlet form the basis of Servlets its important to know What are they and What is main difference between them. From common sense and there names, its obvious that GenericServlet is a generic and protocol-independent implementation of Servlet interface while HttpServlet implements HTTP protocol specifics. If you are working in Java web application or J2EE projects, you are most likely to deal with HttpServlet all time as HTTP is main communication protocol of web. In this Servlet JSP article we will outline some important difference between HttpServlet and GenericServlet which is worth knowing and remembering.

How to iterate over HashSet in Java - loop or traverse Example

Iterating over HashSet in Java
Java program to Iterate over HashSet in Java with ExampleIn our last Java collection tutorial, we have seen How to iterate over ArrayList in Java and in this tutorial we will see How to iterate over HashSet in Java. There are two ways to iterate, loop or traverse over HashSet in Java, first using advanced for-each loop added on Java 5 and second using Iterator which is a more conventional way of iterating over HashSet in Java. Now questions are When should you use for loop and when Iterator is an appropriate option. Well I usually use for loop If I only read from HashSet and doesn't remove any element, while Iterator is preferred approach. You should not remove elements from HashSet while iterating over it in for loop, Use Iterator to do that.

How to Fix java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7 [Solved]

Hello guys, today, we'll take a look at the not-so-common error for Java applications. If you have been working in Java for a couple of years then you might have seen this dreaded "java.lang.VerifyError: Expecting a stack map frame at branch target 14 in method at offset JDK 7" error in your application log or in Eclipse, particularly if you are running your Java application in Java 7. The main cause of this error, "java.lang.VerifyError: Expecting a stack map frame at branch target ... in the method ... at offset 0 error comes when you have some library, JAR file which is only compatible with Java 1.6 or below and you are running your program in JDK 1.7.

When to throw and catch Exception in Java? [Best Practice]

Exceptions are one of the confusing and misunderstood topics in Java, but at the same time, too big to ignore. In fact, good knowledge of Errors and Exception handling practices is one criterion, which differentiates a good Java developer from an average one. So what is confusing about Exception in Java? Well, many things like When to throw Exception or When to catch Exception, When to use checked exception or unchecked exception, should we catch errors like java.lang.OutOfMemoryError? Shall I use an error code instead of an Exception and a lot more? Well, I cannot answer all these questions in one post, so I will pick the first one when to catch or throw any Exception in Java.

How to Fix java.sql.BatchUpdateException: Error converting data type float to numeric - Java + SQL Server

This error can come if you are inserting or updating a NUMERIC column in the Microsoft SQL Server database from a Java Program using the executeUpdate()method, I mean executing a  batch update query. It could also happen if you are calling a stored procedure and passing a float value corresponding to a NUMERIC column, and the value happened to be out-of-range like generating "Arithmetic overflow error converting numeric to data type numeric" on the SQL Server end. For example, if your column is defined as NUMERIC (6,2) the maximum value it can represent is 9999.99, not 999999.99

How to Fix SQLServerException: The index is out of range? JDBC Example

I was executing a stored procedure against SQL SERVER 2008 database from Java program using CallableStatement, but unfortunately, I was getting the following error "SQLServerException: The index 58 is out of range". Since I am passing a lot of parameters I thought that something is wrong with a number of parameters I was passing to the stored proc. My stored procedure had 58 INPUT parameters, as soon as I removed the 58th INPUT parameter the error goes away, which confirmed my belief that SQL Server supports a maximum of 57 INPUT parameters in stored procedure via JDBC

How to deal with java.lang.NullPointerExceptionin Java? Cause, Solution, and Tips to avoid NPE

Hello Java programmers, if you want to learn what is NullPointerExcpeiton in Java and how to deal with NullPointerException or NPE then you have come to the right place. NullPointerException in Java is an unchecked Exception defined in java.lang package and comes when a member of an object either field or method is called on an object which is null. null is a keyword in Java that means nothing and the calling method on an object whose value is null will result in NullPointerException. Since the default value of Object is null, if you call any method or access any field on an Object which is not initialized will throw NullPointerException

How to solve java.sql.BatchUpdateException: String or binary data would be truncated in Java JDBC? [Solution]

Recently I was working in a Java application that uses Microsoft SQL Server at its backend. The architecture of the Java application was old i.e. even though there was heavy database communication back and forth there was no ORM used like no Hibernate, JPA, or Apache iBatis. The Java application was using an old DAO design pattern, where the DB related classes which are responsible for loading and storing data from the database was calling the stored procedure to do their job. These stored procedures take data from Java applications and insert it into SQL Server tables.

How to deal with Unsupported major.minor version 55.0, 57,0, 60.0, 61.0 in Java + Eclipse + Linux [Solution]

The "unsupported major.minor version 55.0" error started to come after Java SE 11 release and the root cause of this error is trying to run a Java application compiled with JDK 11 into a JRE lower than Java SE 11 like JRE 9 or JRE 8. This is very common because a developer has updated their compiler or IDE to Java SE 11 but many times their runtime is not upgraded to Java 11. If you remember, in Java you can run a class file compiled with a lower version say Java 8 to a higher version say JRE 11 because Java is backward compatible but vice-versa is not allowed. I mean, you cannot run a JAR file or class file created by Java 11 version into  Java 8 or Java 9 version. Similarly, you cannot run a Java SE 17 compiled class file in Java SE 11 or Java SE 13 runtime environment.

How to Fix java.lang.NoClassDefFoundError: org/dom4j/DocumentException [Solution]

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException comes when your program is using the DOM4j library but necessary JAR is not present. This error can also come when you are indirectly using the DOM4j library like  when you use the Apache POI library to read the XLSX file in Java,  this library needs dom4j.jar in your classpath. Not just this one but there are several other libraries that use this JAR internally, if you are using any of them but don't have this JAR then your program will compile fine but fail at runtime because JVM will try to load this class but will not be able to find it on the classpath

[Solved] Exception in thread "main" java.lang.IllegalStateException during Iterator.remove() in Java

Hello guys, if you are wondering how to deal with  java.lang.IllegalStateException while trying to remove elements from ArrayList in Java then you have come to the right place. In this article, I am going to share how I solved this problem and how you can do the same. I was writing a sample program to demonstrate how to remove elements from the list while iterating over it by using the Iterator.remove() method. Unfortunately, I was getting the following error, right at the place where I was calling the Iterator.remove() method :

Wednesday, April 19, 2023

What is Synchronized Keyword and Method in Java? Example

synchronized keyword in Java is one of the two important keywords related to concurrent programming in Java, the other being a volatile keyword. the synchronized keyword is used to provide mutual exclusion, thread safety, and synchronization in Java. Unlike Volatile keyword, synchronized keyword is not an application to instance variable and you can only use synchronized keyword either with synchronized method or block. synchronized keyword work with the concept of lock, any thread which holds a lock on which synchronized method or block is locked, can enter otherwise thread will wait till it acquires the lock. In Java programming language every object holds a lock and every class holds a lock, like two String objects s1, s2 holds two different object lock,s and String.class is used to represent class lock.

How to use DROP command to remove tables in Oracle, MySQL and SQL Server

Hello guys, if you want to learn about DROP command in SQL then you have come to the right place. Earlier, I have shared the best free SQL and Database courses and several tutorials to learn SELECT, GROUP BY, and other important commands, and in this article, I will show you to use the DROP command in SQL. DROP is one of the basic SQL commands, which is used to DROP database objects. Since it's part of ANSI SQL, the DROP command is supported by all major database vendors, including Oracle, MySQL, and Microsoft SQL Server. A SQL DROP TABLE statement is used to delete a table definition and all data from a table, but DROP can also be used to drop index, view, trigger, or any other database object. 

[Solved] Caused by: java.sql.SQLSyntaxErrorException: ORA-01722: invalid number in Java and Oracle

Hello guys, if you are getting below error in your Java program and wondering how to solve this or just stuck then you have come to the right place. In this article, I will explain to you what causes the " java.sql.SQLSyntaxErrorException: ORA-01722: invalid number" error when you connect to an Oracle database from a Java program and how you can solve it. 

But, first of all, let's take a look at the stack trace of this error which looks like below:

10 Essential SQL Commands and Functions Every Developer should learn

Hello guys, if you are starting with SQL and wondering which commands you should learn first then you have come at the right place. In this article, I have shared 10 most essential SQL commands and functions which I believe every programmer should learn. This includes commands to pull data from database as well write data into data, update data, and remove data from database. While writing in the SQL language, you will utilize an assortment of SQL keywords to make explanations and questions. An assertion includes a series of characters and SQL keywords that adjusts to the designing and grammar rules of the language and may influence information or control processes corresponding to your information. 

How to convert String to Integer SQL and Database? MySQL, Oracle, SQL server and PostgreSQL Example

 Hello guys, if you are wondering how to convert VARCHAR to String in SQL then you are at the right place. In this article, we will cover various techniques to convert String to Integer in all databases - MySQL, Oracle, SQL server and PostgreSQL. To perform tasks or correlations or change between information in a SQL Server data set, the SQL information kinds of those values should coordinate. At the point when the SQL information types are unique, they will go through a cycle called type-projecting. The transformation of SQL information types, in this cycle, can be implied or unequivocal.

What is Normalization in SQL? 1NF, 2nd NF, 3rd NF and BCNF Example Tutorial

What is Normalization?
Normalization is one of the essential concept of relational database. It is the process or technique to remove duplicate data from tables and thus reduce the storage size. It also helps to maintain integrity of data. Normalization likewise assists with coordinating the information in the data set. It is a multi-step process that sets the information into even structure and eliminates the copied information from the relational tables. Normalization coordinates the segments and tables of a data set to guarantee that data set integrity constraints appropriately execute their conditions. It is an orderly method of deteriorating tables to take out information overt repetitiveness (redundant) and unfortunate qualities like Insertion, Update, and Deletion anomalies.

What is temporary table in Database and SQL? Example Tutorial

Hello folks, if you have heard the term temporary table online or by your colleague in a call and wondering what is temporary table, what is the difference between a normal table and a temporary table, and when and how to use it then you have come to the right place. In this blog, we shall learn how to use a temporary table in SQL. But before we go into that we need an overview of SQL. What is SQL? SQL stands for Structured query language. it is a programming language used in communicating or relating to the relational database. And this programming language performs various forms of operation in the data. It was created in the 1970s, SQL is used by database administrators, and developers writing data integration scripts, etc.

How to use EXISTS and NOT EXISTS in SQL? Microsoft SQL Server Example

Hello guys, if you are wondering how to use the IF EXISTS and NOT EXISTS in SQL then you are at the right place. Earlier, I have shared how to use GROUP BY, WHERE, and HAVING clause and in this tutorial I will share how to use exists and not exists clause in SQL. The IF EXISTS and NOT EXISTS commands in T-SQL are covered in depth in this article. When comparing data sets using subqueries, it also illustrates why EXISTS should be preferred over IN and NOT EXISTS over NOT IN. If you don't know, EXISTS is a logical operator in SQL that is used to check if rows in a database exist. If the subquery produces one or more records, it returns TRUE. The NOT EXISTS operator in SQL is the polar opposite of the EXISTS operator, and it is fulfilled if the subquery returns no results.

Tuesday, April 18, 2023

Top 20 AWS Interview Questions Answers for Developers and DevOps Engineers

Hello guys, if you are preparing for Cloud engineer interview or preparing for a developer role where AWS cloud skills are required and need AWS questions to kick start your preparation then you have come to the right place. Earlier, I have shared 20 Cloud Computing Interview Questions with answers and in today's article, I am going to share 20 common AWS questions with answers from interviews. These questions are suitable for 1 to 3 years experienced AWS professionals as it touches fundamental AWS concepts and services. If you have worked on AWS platform then most likely you can answer all of these questions but if you struggle then you can always go back and join one of these best AWS cloud courses to learn and revise key AWS concepts before interviews. 

Top 51 JavaScript Interview Questions for 1 to 2 Years Experienced Developers

Hello guys, you may know that JavaScript is one of the most popular programming languages, having ranking #1 for a couple of years in the StackOverflow survey. There is no doubt that JavaScript is the most popular language or web development. The best thing is that you can use JavaScript to develop both frontend and backend using the same programming language and tech stack. You have so many popular frameworks like React.js, Angular, Node.js, Vue.js to implement sophisticated web applications for different domains. That's why the demand for JavaScript developers is very high, especially full-stack JavaScript developers who can create front-end and back-end applications independently.

Top 50 Advanced Java Garbage Collection and Performance Interview Questions and Answers

Hello Java Developers, If you have gone through any Java Developer interview, particularly for a senior developer role then you know that a good knowledge of JVM internals and Garbage collection is important. Even though Java and JVM take care of memory management for you, bad code can still cause memory leaks and performance issues. For example, if you are creating millions of objects in a loop or keeping an un-intended reference of dead objects then you are putting additional strain on the Garbage collector and creating a memory leak in your application. You cannot blame Java and JVM for that and the only way to avoid such errors is to know about how Garbage collection works.

Top 50 Database and SQL Interview Questions Answers for Programmers

Hello guys, whether you are preparing for Java developer interview or any other Software Developer Interview, a DevOps Interview or a IT support interview, you should prepare for SQL and Database related questions. Along with Data Structure, Algorithms, System Design, and Computer Fundamentals, SQL and Database are two of the essential topic for programming or technical Job interview. In the past, I have shared many questions related to MSSQL questions, Oracle Questions, MySQL questions, and PostgreSQL questions and in this article, I am going to share both theory based and query based Database and SQL Interview questions with to the points answers.

Top 27 Spring Security Interview Questions Answers for Java Developers

Hello guys, if you are preparing for Java and Spring Developer interview then you should prepare about Spring Security. Since Security is an important topic and Spring security is the most popular framework to implement security in Java web applications, there is always a few questions based upon Spring Security in Java developer interviews. In the past, I have shared Spring Boot questionsSpring Data JPA Question, Spring Cloud Questions, and Microservices Interview Questions and in this article, I will share 20 popular Spring security questions for practice. I have also shared answers so that you can revise key Spring security concepts quickly but if you think that you need more preparation on certain topic then you can also checkout this list of best Spring Security courses where I have shared online courses to learn Spring security in depth. 

Monday, April 17, 2023

What is HashSet in Java? Example Tutorial

Hello guys, we meet again for our journey of learning Java. Today, we are gonna learn something very fruitful and easy. Hope you all are excited and ready. I would recommend you guys to go through the HashMap or TreeMap article which goes over hashing as this topic has some of its features. So, What's the wait? Let's start! Suppose you guys are given the task of storing car names (yes, I love cars :p). Now, how would you store it? If you guys have some questions, here are the requirements. The car names may increase over time. So, logically, an array is not what we are looking for. 

What is Blocking Deque in Java? How and When to use BlockingDeque? Example Tutorial

Hello friends, we meet again here today on our journey to Java. Before we continue forward, let me inform you guys that today's topic is in continuation of our Java Deque topic. If any of you guys have not read the Java Deque tutorial, go ahead and read that one first. Though there is no such limitation of this article, it is recommended to have gone through the basics of Deque and our previous post. So, I guess now we will continue our Deque topic and today we will discuss something very interesting. Today we are gonna jump into the advanced topic of Deque and how we can leverage the functionality Java has provided for a better and more robust application building.

How to find 2nd, 3rd or kth element from end in linked list in Java? Example [Solved]

Hello guys, today, I am going to discuss one of the important linked list based coding problems from interviews - how to find the Kth element from the end? This question is also asked as to how do you find the 3rd element from the last of a singly linked list in one pass or write a Java program to find the 5th element from the tail of a given linked list in one iteration. In this article, you will learn the programming technique so that you can solve any variant of this problem, I mean the Kth node from the tail problems and some linked list-based challenges. The difficulty in this question is that you need to solve the problem in one iteration or one pass. This means you cannot traverse the linked list again. I mean you cannot go till the end then traverse back to the Kth element.

10 Examples of an Array in Java

Along with the String, the array is the most used data structure in Java. In fact, String is also backed by a character array in Java and other programming languages. It's very important for a Java programmer to have good knowledge of array and how to do common things with array e.g. initialization, searching, sorting, printing array in a meaningful way, comparing array, converting an array to String or ArrayList, and doing some advanced slicing and dicing operation with an array in Java. Like my previous tutorials 10 examples of HashMap in Java, I'll show you some practical examples of an array in Java. If you think, any important operation is not included, you can suggest their examples and I'll add them to this list.

3 Examples of flatMap() of Stream in Java

Hello guys, if you are doing Java development then you must have come across the flatMap() method on Stream and Optional Class. The flatMap() method is extension of map() function as it does both flattening and mapping (or transformation) instead of just transformation done by map() method. I have explained the difference between map() and flatMap() earlier in detail, but just to revise, let's revisit it. If you have a list of String e.g. {"credit", "debit", "master", "visa"} then you can use the map() method to get a list of integer where each value is length of corresponding String e.g. list.stream().map(s -> s.length()) will produce {6, 5, 6, 4}. This is called transformation because you have transformed an stream of String to a Stream of integer

Saturday, April 15, 2023

How to fix cannot determine embedded database driver class for database type NONE

Hello and welcome to the blog post. Today we are going to take a look at a frequently encountered problem in Spring Boot Application. If you are reading this, I'm going to assume that you saw the problem "Cannot determine embedded database driver class for database type NONE" while executing a Spring Boot application. We will understand, when this error appears. For this we will create a simple Spring Boot project as shown below. It demonstrates how I encountered the problem "Cannot determine embedded database driver class for database type NONE".  

Friday, April 14, 2023

Write a Program to Find Sum of Digits in Java

One of the common programming practice question thrown to beginners is to write a program to calculate the sum of digits in an integral number. For example, if the input is 123456 then output or sum of the digit is (1+2+3+4+5+6) = 21. An additional condition is you can not use any third party or library method to solve this problem. This program is not as simple as it looks and that's why it's a good exercise, you must know some basic programming techniques e.g. loops, operators, and logic formation to solve this problem. Let's see how we can solve this problem using Java programming language. In order to calculate the sum of digits, we must get digits as numbers. So your first challenge is how do you get the digits as numbers?  How do we extract 6 out of 123456?

How to use Multiple Catch block for Exception handling in Java? Example Tutorial

Java 7 in many ways improved exception handling. Two of the feature of Java 7 which improves exception handling are the ability to catch the multiple exceptions in one catch block and closing resources automatically using Automatic resource management block. Java has long been criticized for its verbose exception handling code, mandatory to handle checked Exceptions in Java. Programmers always complained that it clutters the code and reduced readability. Java 7 somehow reduces this pain by improving the Exception handling feature e.g. multiple catches and ARM blocks. In this Java 7 tutorial, we will see how to catch multiple exceptions in one catch block using JDK7.

How to format Date in Java - SimpleDateFormat Example

SimpleDateFormat in Java is used to format Date in Java. You can format date on any String format based upon various attribute available in SimpleDateFormat class e.g. mm, dd, YY etc. You can also put timezone information in formatted Date using Z attribute of DateFormat class. SimpleDateFormat is sub class of DateFormat and provide format() and parse() method to convert Date to and from String in Java. Worth noting is that SimpleDateFormat is not thread-safe and should not be shared with others. Avoid using static SimpleDateFormat in Java classes. If you want to share SimpleDateFormat or want to make it thread-safe, you can use ThreadLocal variable in Java to avoid sharing SimpleDateFormat among multiple threads. parse() method of SimpleDateFormat throws ParseException if String input is not a valid date or can not be parsed into mentioned format.

Difference between URL, URI and URN - Interview Question

All three URI, URL, and URN are used to identify any resource or name on the internet, but there is a subtle difference between them. URI is the superset of both URL and URN. By the way, the main difference between URL and URI is protocol to retrieve the resource. URL always include a network protocol e.g. HTTP, HTTPS, FTP etc to retrieve a resource from its location. While URI, in case of URN just uniquely identifies the resource e.g. ISBN numbers which are a good example of URN is used to identify any book uniquely. In this article, we will briefly see what is URI, URL, and URN and then see the main difference between URI, URL, and URN.

How to traverse iterate or loop ArrayList in Java

How to Loop ArrayList in Java
Iterating, traversing or Looping ArrayList in Java means accessing every object stored in ArrayList and performing some operations like printing them. There are many ways to iterate, traverse or Loop ArrayList in Java e.g. advanced for loop, traditional for loop with size(), By using Iterator and ListIterator along with while loop etc. All the method of Looping List in Java also applicable to ArrayList because ArrayList is an essentially List. In next section we will see a code example of Looping ArrayList in Java.

How to use Java Enum in Switch Case Statement - Exampel Tutorial

Java Enum in Switch Case Statement
Yesterday, someone ask me Can we use Java Enum in Switch case? Obviously, he was learning Enum and not aware that How powerful Enum in Java is. Yes, You can use Enum in Switch case statement in Java like int primitive. If you are familiar with enum int pattern, where integers represent enum values prior to Java 5 then you already knows how to  use the Switch case with Enum. Using Java Enum in the Switch case is pretty straightforward, Just use Enum reference variable in Switch and Enum constants or instances in CASE statement. In this Java tutorial we will see one example of How to use Enum in Switch statement in Java

What is CopyOnWriteArrayList in Java - Example Tutorial

CopyOnWriteArrayList vs Array List in Java
CopyOnWriteArrayList is a concurrent Collection class introduced in Java 5 Concurrency API along with its popular cousin ConcurrentHashMap in Java. CopyOnWriteArrayList implements List interface like ArrayList, Vector, and LinkedList but its a thread-safe collection and it achieves its thread-safety in a slightly different way than Vector or other thread-safe collection class. As the name suggests CopyOnWriteArrayList creates a copy of underlying ArrayList with every mutation operation e.g. add, remove, or when you set values. That's why it is only suitable for a small list of values which are read frequently but modified rarely e.g. a list of configurations.

Difference between Error vs Exception in Java - Interview question

Both Error and Exception are derived from java.lang.Throwable in Java but main difference between Error and Exception is kind of error they represent. java.lang.Error represent errors which are generally can not be handled and usually refer catastrophic failure e.g. running out of System resources, some examples of Error in Java are java.lang.OutOfMemoryError or Java.lang.NoClassDefFoundError and java.lang.UnSupportedClassVersionError. On the other hand java.lang.Exception represent errors which can be catch and dealt e.g. IOException which comes while performing I/O operations i.e. reading files and directories.

Java program to get SubList from ArrayList - Example

Sometimes we need subList from ArrayList in Java. For example, we have an ArrayList of 10 objects and we only need 5 objects or we need an object from index 2 to 6, these are called subList in Java. Java collection API provides a method to get SubList from ArrayList. In this Java tutorial, we will see an example of getting SubList from ArrayList in Java. In this program, we have an ArrayList which contains 4 String objects. Later we call ArrayList.subList() method to get part of that List.

Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

Hello and welcome to the blog post. In this post, we are about to take a look at how to fix the ‘unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean’ in the spring boot application. Let’s understand how to fix this error. But before we dig deep into this issue. Let’s first have a look at when this error appears. 


Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean

The error appears with the following stack trace.

Exception in thread “main” org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:140)

at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:476)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:124)

at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:658)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:355)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:920)

at org.springframework.boot.SpringApplication.run(SpringApplication.java:909)

at Application.main(Application.java:17)

Caused by: org.springframework.context.ApplicationContextException: Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.getEmbeddedServletContainerFactory(EmbeddedWebApplicationContext.java:190)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.createEmbeddedServletContainer(EmbeddedWebApplicationContext.java:163)

at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.onRefresh(EmbeddedWebApplicationContext.java:137)

… 7 more 


Now, let's see some code to understand when this error comes and how to fix it:


SpringBootPracticeApplication.java


package com.practice.springboot;



import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootConfiguration;



@SpringBootConfiguration

public class SpringBootPracticeApplication {



   public static void main(String[] args) {

      SpringApplication.run(SpringBootPracticeApplication.class, args);

   }



}



pom.xml


<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

   <modelVersion>4.0.0</modelVersion>

   <parent>

      <groupId>org.springframework.boot</groupId>

      <artifactId>spring-boot-starter-parent</artifactId>

      <version>3.0.4</version>

      <relativePath/> <!-- lookup parent from repository -->

   </parent>

   <groupId>com.practice</groupId>

   <artifactId>spring-boot</artifactId>

   <version>0.0.1-SNAPSHOT</version>

   <name>Spring Boot Practice</name>

   <description>Spring Boot Practice Project</description>

   <properties>

      <java.version>17</java.version>

   </properties>

   <dependencies>

      <dependency>

         <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-web</artifactId>

      </dependency>



	 <dependency>

       <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-test</artifactId>

         <scope>test</scope>

	</dependency>

   </dependencies>

</project>


As you can see from the above program, we have a very simple spring boot project that fails to run as intended. There are a couple of possible solutions to this program. These approaches are discussed below.


How to fix this error?

First of all you need to ensure that your main class has the @SpringBootApplication annotation.

The @SpringBootApplication annotation is comparable to the @EnableAutoConfiguration, @ComponentScan, and @Configuration annotations with their default properties, i.e., allow adding new beans to the context or importing more configuration classes.


SpringBootPracticeApplication.java -- updated

package com.practice.springboot;



import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;



@SpringBootApplication

public class SpringBootPracticeApplication {



   public static void main(String[] args) {

      SpringApplication.run(SpringBootPracticeApplication.class, args);

   }



}


If you have followed the above step or your starter file already contains @SpringBootApplication, you need to make sure your pom.xml file also includes the spring-boot-starter-web or spring-boot-starter-tomcat dependencies, as demonstrated in the example below.
<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

   <modelVersion>4.0.0</modelVersion>

   <parent>

      <groupId>org.springframework.boot</groupId>

      <artifactId>spring-boot-starter-parent</artifactId>

      <version>3.0.4</version>

      <relativePath/> <!-- lookup parent from repository -->

   </parent>

   <groupId>com.practice</groupId>

   <artifactId>spring-boot</artifactId>

   <version>0.0.1-SNAPSHOT</version>

   <name>Spring Boot Practice</name>

   <description>Spring Boot Practice Project</description>

   <properties>

      <java.version>17</java.version>

   </properties>

   <dependencies>

      <dependency>

         <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-web</artifactId>

      </dependency>



	 <dependency>

       <groupId>org.springframework.boot</groupId>

         <artifactId>spring-boot-starter-test</artifactId>

         <scope>test</scope>

	</dependency>



<!-- Add spring-boot-starter-web or spring-boot-starter-tomcat -->



<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-tomcat</artifactId>

</dependency>



<!-- Add spring-boot-starter-web or spring-boot-starter-tomcat -->



   </dependencies>

</project>


After following the above two approaches, the error finally disappeared and the spring application start successfully as shown from the console.

 .   ____          _            __ _ _

 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \

( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \

 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )

  '  |____| .__|_| |_|_| |_\__, | / / / /

 =========|_|==============|___/=/_/_/_/

 :: Spring Boot ::                (v3.0.4)


2023-03-09T09:46:05.540+05:00  INFO 40009 --- [           main] c.p.s.SpringBootPracticeApplication      : Starting SpringBootPracticeApplication using Java 19.0.1 with PID 40009 (/home/muhammad/IdeaProjects/spring-boot/target/classes started by muhammad in /home/muhammad/IdeaProjects/spring-boot)

2023-03-09T09:46:05.545+05:00  INFO 40009 --- [           main] c.p.s.SpringBootPracticeApplication      : No active profile set, falling back to 1 default profile: "default"

2023-03-09T09:46:06.501+05:00  INFO 40009 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)

2023-03-09T09:46:06.509+05:00  INFO 40009 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]

2023-03-09T09:46:06.510+05:00  INFO 40009 --- [           main] o.apache.catalina.core.StandardEngine    : Starting Servlet engine: [Apache Tomcat/10.1.5]

2023-03-09T09:46:06.585+05:00  INFO 40009 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext

2023-03-09T09:46:06.585+05:00  INFO 40009 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 972 ms

2023-03-09T09:46:06.964+05:00  INFO 40009 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''

2023-03-09T09:46:06.972+05:00  INFO 40009 --- [           main] c.p.s.SpringBootPracticeApplication      : Started SpringBootPracticeApplication in 1.927 seconds (process running for 2.661)


Conclusion

That's all about how to fix "Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean" error in Spring Boot. . The main subject of this post is the Spring Boot problem Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean. 

We have explored two methods to address this issue. The first step is to choose the appropriate Spring annotation, and the second is to add the missing dependency to your build.gradle or pom.xml file. I hope the information in this post has helped you to correct the issue. For more such helpful articles keep following us.