Administrator

Lokesh Gupta

Lokesh Gupta is a Java developer with more than 20 years of experience and the founder of HowToDoInJava, which he started in 2012. He has worked on Java and Spring applications at Hewitt Associates, Hughes Systique, Adobe and Bank of America. The site has over 1,600 tutorials on Java, Spring Boot, Hibernate, testing and TypeScript. Every example is run and verified before it is published, and the source code is on GitHub.

Website: https://howtodoinjava.com

Github: https://github.com/lokeshgupta1981/

Twitter: @HowToDoInJAVA

LinkedIn: https://www.linkedin.com/in/lokeshgupta1981/

My Articles:

Spring Authorization Server Tutorial (Spring Boot 4)

Spring Authorization Server issues OAuth2 access tokens and OpenID Connect ID tokens from our own Spring Boot application. This tutorial builds an authorization server and a resource server on Spring Boot 4.1, with client_credentials and PKCE clients, key rotation, custom claims, JDBC client storage, MockMvc tests and real curl output.

Spring Boot Thymeleaf Tutorial: Forms, Fragments, Tests

Thymeleaf renders server-side HTML pages from natural templates in a Spring Boot application. This tutorial builds a playlist app on Spring Boot 4.1.1 and Thymeleaf 3.1.5 with loops, conditions, links, validated forms, fragments, i18n and date and number formatting, and tests the views with MockMvcTester.

ArchUnit Tutorial: Test Java Architecture with JUnit 6

ArchUnit checks the structure of Java code, such as layers, package cycles, naming and Spring annotations, inside ordinary JUnit 6 tests. This tutorial sets up archunit-junit6 1.5.1, writes layered, onion and Spring Boot rules, reads real failure messages and freezes rules for legacy code.

AssertJ Tutorial: Fluent Assertions Cheat Sheet for JUnit 6

AssertJ is a Java assertion library where we chain readable checks on assertThat(actual) and get failure messages that name the exact difference. This tutorial covers strings, numbers, collections, maps, Optional, exceptions, records, java.time, soft assertions, custom assertions and MockMvcTester in Spring Boot, with a cheat sheet table.

Spring Cloud Gateway Tutorial with Spring Boot 4 Examples

Spring Cloud Gateway puts one entry point in front of our microservices and routes each request with predicates and filters. This tutorial builds a complete gateway on Spring Boot 4.1 with YAML and Java routes, Redis rate limiting, retry, a Resilience4j circuit breaker, CORS, WireMock tests and the actuator endpoints.

Module Import Declarations in Java 25: import module

A module import declaration such as import module java.base; imports every package a module exports with one line, and it is final in Java 25. Learn what it imports, how to fix “reference to List is ambiguous” with a single-type import, and how it works with java.se and compact source files.

TypeScript Utility Types: Partial, Pick, Omit and Record

TypeScript utility types create new types from an existing one, such as an all-optional copy or a subset of keys. This reference lists all 22 built-in utility types with their results, gives one example each for Partial, Pick, Omit, Record, Exclude, ReturnType and Awaited, and shows the real tsc errors we get when we use them wrong.

NoSuchMethodError in Java: Causes, Diagnosis and Fix

java.lang.NoSuchMethodError means code compiled against one version of a class runs with another version that lacks the called method. Learn to read the message, find the wrong jar with mvn dependency:tree, -verbose:class and javap, and fix the conflict with a BOM, an exclusion and the Enforcer dependencyConvergence rule.

StackOverflowError in Java: Causes, Stack Trace and Fixes

A StackOverflowError means a thread made more nested calls than its stack can hold. Learn to read the repeating stack trace, fix missing base cases, deep recursion and object cycles in toString(), Lombok and Jackson, and when -Xss helps.

IllegalArgumentException in Java: Real Causes and Fixes

IllegalArgumentException is the unchecked exception a Java method throws when an argument has a value it does not accept. This post lists the JDK calls that throw it with their real Java 25 messages and the fix for each, the subclasses such as NumberFormatException, and when our own code should throw it instead of IllegalStateException or NullPointerException.

TypeScript satisfies Operator: vs as and as const satisfies

The TypeScript satisfies operator checks a value against a type and keeps the narrow type TypeScript inferred for it. We compare satisfies with type annotations and as assertions, use it on settings objects, Record maps and as const tables, and read the real tsc errors for the common mistakes.

Spring Boot Microservices Tutorial (Spring Boot 4 Example)

Spring Boot microservices are small Spring Boot applications that each own one business capability and call each other over the network. This tutorial builds a complete library system on Spring Boot 4.1 with Spring Cloud Gateway, HTTP interface clients, Resilience4j retry and circuit breaker, OpenTelemetry tracing with one trace id across services, Docker Compose and WireMock tests, and explains when not to use microservices.

Java CompletableFuture Tutorial with Examples (Java 25)

A CompletableFuture is a Future that runs the next step when its result arrives, so no thread has to wait for it. This tutorial creates, chains and combines CompletableFuture tasks on virtual threads, handles errors and timeouts, and shows the mistakes that make async code hang or lose exceptions.

TypeScript Decorators: Method, Class and Field Examples

A TypeScript decorator is a function that we put above a class or class member with @name, and it can replace that member with a new version. Learn each decorator kind with runnable TypeScript 7 examples, the order decorators run in, the usual compiler errors, and how standard decorators differ from experimentalDecorators used by Angular, NestJS and TypeORM.

Kafka Queues: Share Groups (KIP-932) with Spring Kafka

Kafka queues let many consumers in a share group read the same partition and acknowledge each record on its own. This guide compares share groups with consumer groups, lists the status in Kafka 4.x and the broker settings, and builds a Spring Kafka share consumer with acknowledge, release and reject.

Spring Boot 4 Tutorial: What’s New in 4.0 and 4.1 (Examples)

Spring Boot 4 is the major release built on Spring Framework 7, Jakarta EE 11 and Jackson 3, with Java 17 as the minimum. This tutorial builds one Spring Boot 4.1.1 app that shows the modular starters, JSpecify null-safety with NullAway, API versioning, HTTP service clients with @Retryable, Jackson 3, MockMvcTester and RestTestClient tests, virtual threads, OpenTelemetry traces and the 4.1 additions, and ends with an upgrade checklist from Spring Boot 3.5.

TypeScript 6: New Features, New Defaults and Deprecations

TypeScript 6 is the last TypeScript release with a JavaScript-based compiler. It changes tsconfig.json defaults such as strict and types, and deprecates options that TypeScript 7 removes. This overview lists every change with the real tsc errors and an upgrade checklist for 5.x projects.

TypeScript 7 vs TypeScript 6: Native Go Compiler Explained

TypeScript 7 is the Go port of the TypeScript compiler and checks the same language as TypeScript 6 about 10 times faster. We compare both versions in a table, time tsc 6.0.3 and tsc 7.0.2 on the same project, and show what still needs TypeScript 6 and how to switch.

Spring Framework 7: What’s New, Features and Examples

Spring Framework 7 keeps Java 17 but moves to Jakarta EE 11, JSpecify null-safety and Jackson 3. This overview lists every notable change in a summary table and shows the main new features, such as @Retryable, API versioning and BeanRegistrar, with short examples.

Jackson 3 Migration: Upgrade From Jackson 2 to Jackson 3

Jackson 3 moves to the tools.jackson group id and packages, makes JsonMapper immutable and replaces the checked JsonProcessingException with JacksonException. This guide shows each change with a short snippet, the changed defaults side by side, how Spring Boot 4 uses Jackson 3, and a migration checklist.

Gradle 9: What’s New and How to Upgrade from Gradle 8

Gradle 9 needs Java 17 or newer to run, builds scripts with Kotlin 2 and Groovy 4, and removes the APIs that Gradle 8 deprecated. This overview lists the main changes from 9.0 to 9.8.0, builds a Java 25 project with the Gradle 9 wrapper, and fixes the most common upgrade errors.

Mockito 5 Tutorial With JUnit 6 and Java 25 Examples

Mockito 5 creates mocks for a class’s dependencies and mocks final classes and static methods with mockito-core alone. This tutorial sets up Mockito 5.24.0 with JUnit 6 on Java 25, including the Java agent setup, and covers stubbing, verify, matchers, captors, spies, mockStatic and the strict stubs errors.

Spring Security 7: What’s New and How to Migrate From 6.x

Spring Security 7 ships with Spring Boot 4 and removes the APIs deprecated in 6.x, such as and() chaining and AntPathRequestMatcher. This overview lists every change in one table, explains each one briefly with snippets for the main ones, and ends with a migration checklist from 6.x.

Java 25 Migration: Upgrade From Java 21 Step by Step

A Java 25 migration is mostly a build change. This step-by-step guide upgrades a Maven project from Java 21 to Java 25, shows the support dates, and fixes the real errors from Lombok, Mockito and JaCoCo on the way.

Java 25 Features (LTS): All 18 JEPs With Code Examples

Java 25 is the LTS release of September 2025 with 18 JEPs. This guide runs every one of them, from compact source files, module imports, flexible constructors and scoped values to compact object headers, AOT caches and the new JFR events, and shows the preview features with their –enable-preview flags. It ends with the features that became final between Java 21 and 25 and a migration checklist.

Java 26 Features: All 10 JDK 26 JEPs with Code Examples

Java 26 (JDK 26) shipped on 17 March 2026 as a non-LTS release with 10 JEPs. This overview lists every JEP with its status and shows short, runnable examples for HTTP/3, final field warnings, the AOT cache with ZGC and the preview APIs.

Java 27 Features: All 9 JEPs in JDK 27 with Examples

Java 27 (JDK 27) reached general availability on 15 September 2026 with nine JEPs. Four final JEPs change JVM defaults (G1 everywhere, compact object headers, post-quantum TLS, JFR redaction), and five continue as previews or incubator. A summary table, one example per feature and the removed options.

Java List Initialization in One Line: List.of and ArrayList

Initialize a Java List in one line with List.of() for an unmodifiable list, or new ArrayList<>(List.of(…)) when the list changes later. Compare Arrays.asList(), Stream.toList(), Collections and Guava by mutability and null support.

Maven 4: What’s New and How to Migrate from Maven 3

Maven 4 separates the build POM from the published consumer POM, which brings POM model 4.1.0, subprojects, inferred versions, BOM packaging and new lifecycle phases. Maven 4.0.0 is still a release candidate (4.0.0-rc-7), so this guide builds the same project with Maven 3.9.16, 3.10.0 and 4.0.0-rc-7, shows what fails and walks through the migration with mvnup.

Java Interview Questions for 5 Years of Experience

30 Java interview questions for developers with about 5 years of experience, each with a direct answer, the reason behind it and a runnable Java 25 snippet. Covers collections internals, concurrency, Java 21 to 25 features, JVM memory and GC, streams, design, Spring @Transactional pitfalls and small system design tasks.

Unsupported Class File Major Version 69: Fix for Java 25

“Unsupported class file major version 69” means a JVM or bytecode tool older than Java 25 tried to read a Java 25 class file. Learn to read the class file version, map it to the Java release, and fix the error by upgrading the runtime, compiling with –release, or upgrading Gradle, Spring, JaCoCo, Mockito and Lombok.

Spring Boot Quartz Scheduler: Jobs, Triggers, JDBC Store

Schedule jobs in Spring Boot 4 with Quartz 2.5: inject Spring beans into jobs, use simple and cron triggers, handle misfires, chain jobs with listeners, persist and cluster jobs with the JDBC job store, and manage them from the actuator endpoint.

Kubernetes for Beginners: Hands-On Guide With Spring Boot

A hands-on Kubernetes guide for Java developers: deploy a Spring Boot API and PostgreSQL to a local kind cluster and learn pods, Deployments, Services, Ingress, ConfigMaps, Secrets, volumes and StatefulSets with real kubectl output.

Spring Boot: Import Excel File into Database (Apache POI)

Upload an .xlsx class roster to a Spring Boot endpoint, read it with Apache POI, validate every row with Bean Validation and save the valid rows in JDBC batches. Includes a JSON error report, duplicate checks, a SAX reader for large files with measured heap, upload limits and MockMvc tests.

Spring Boot Hibernate 7 Example with Spring Boot 4.1

Set up Hibernate 7.4 in a Spring Boot 4.1 application: the JPA starter, datasource and JPA properties, entities, Spring Data repositories, transactions, the Session API, SQL logging, tests on H2 and MySQL, and the Hibernate 7 upgrade changes.

Java Random Number Generators in Multithreaded Code

A shared Random is thread-safe but makes every thread fight over one seed. Learn which generator each thread should use, how to keep seeded results reproducible, and what a JMH benchmark measured on Java 25.

How to Fix MySQL Innodb_Force_Recovery Not Working Issue?

The innodb_force_recovery option starts MySQL in a recovery mode that lets the InnoDB storage engine run on a corrupted database, so we can dump the data before we rebuild the damaged tables. When innodb_force_recovery is not working, the cause is either a problem in the option file or corruption that …

About Us

HowToDoInJava provides tutorials and how-to guides on Java and related technologies.

It also shares the best practices, algorithms & solutions and frequently asked interview questions.