Administrator

Lokesh Gupta

A fun-loving family man, passionate about computers and problem-solving, with over 15 years of experience in Java and related technologies. An avid Sci-Fi movie enthusiast and a fan of Christopher Nolan and Quentin Tarantino.

Website: https://howtodoinjava.com

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

Twitter: @HowToDoInJAVA

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

My Articles:

Tomcat Maven Plugin Example

In this maven tutorial, learn to add and configure tomcat plugin to pom.xml and use it deploy the web application without any tomcat installation in machine.

Spring @GetMapping and @PostMapping

Learn to create Spring MVC controllers and map requests with request mapping annotations e.g. @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping and @PatchMapping.

Boxed Streams in Java

In java 8, to convert a stream of primitives to collection, you must first box the elements in their wrapper class and then collect them i.e. boxed stream.

Spring 5 New Features and Upgrades

Spring 5 is the first major release, almost four years after Spring Framework 4.0. Lets quickly go through some exciting features coming in Spring 5.0.

Java 9 Features and Enhancements

Java 9 is bringing lots of new enhancements which are going to affect your programming style and habit, in big way. The biggest change is the modularization of Java. It’s another big change after Lambdas in Java 8. In this article, I am listing down changes which will be part …

Java Platform Module System – JPMS Tutorial

JPMS (Java Platform Module System) is the major enhancement in Java 9. It is also known as Project Jigsaw. In this Java 9 modules tutorial, we will learn about modules (in general) and how your programming style will change in future when you will start writing modular code.

Java 9 – JShell

JShell allows us to execute Java code snippets and get immediate results without having to create a solution or project or using any code editor.

Get all Dates between Two Dates as Stream

Date and time handling has always been a pain area for Java developers. The new Date-Time API added in Java 8 changed the way, we interact with date and time in Java. New Date API is a very powerful and much-needed improvement. The only thing missing was, getting a stream …

Private Methods in Interface – Java 9

Java 9 onward, you are allowed to include private methods in interfaces. Using private methods, now encapsulation is possible in interfaces as well. In this java 9 tutorial, we will learn about interface private methods in detail. Table of Contents Interfaces till Java 7 Static and defaults methods since Java …

Adding Role Based Security with Spring Boot REST APIs

Learn to create JAX-RS 2.0 REST APIs using Spring Boot and Jersey framework, and add role based security using JAX-RS annotations e.g. @PermitAll, @RolesAllowed or @DenyAll. Table of Contents Project Structure Create REST APIs Secure REST APIs with JAX-RS Annotations Write security filter using JAX-RS ContainerRequestFilter Demo Project Structure The …

Create Jersey REST APIs with Spring Boot

Learn to configure and create JAX-RS 2.0 REST APIs using Spring Boot and Jersey framework. This example application uses Jersey’s ServletContainer to deploy the REST APIs.

Java Inheritance

Java Inheritance refers to the ability of a child class to inherit all the non-private properties and methods from the parent class.

Lucene RAMDirectory Example

In this Lucene 6 tutorial, we will learn to use RAMDirectory to run quick examples of POCs because it is not intended to work with huge indexes.

Lucene UnifiedHighlighter Example

Lucene UnifiedHighlighter is the highest-performing highlighter, especially for large documents. Tutorial to highlight search terms in indexed documents/files.

Lucene Search Highlight Example

In Lucene highlighter example, learn to search in documents and highlight search terms in search results using SimpleHTMLFormatter and Fragmenter.

JSON.simple – Read and Write JSON

JSON.simple is lightweight JSON processing library which can be used to read JSON, write JSON file. Produced JSON will be in full compliance with JSON specification (RFC4627).

Read XML with JDOM2 Parser in Java

JDOM parser can be used to read XML, parse xml and write XML file after updating content of it. It stores JDOM2 document in memory to read xml values.

Java 8 Method Reference (with Examples)

Since Java 8, in simplest words, the method references are a way to refer to methods or constructors without invoking them. Learn the syntax with examples.

Convert Byte[] to String and Vice-versa

Learn to convert byte[] to String and String to byte[] in java – with examples. Conversion between byte array and string may be used in many cases including IO operations, generate secure hashes etc.

Convert String to int in Java

learned to parse a string (decimal, octal and hexadecimal) to int or Integer types using Integer.parseInt(), valueOf() and decode() methods.

Java Enum with Strings

In this guide to Java enum with string values, learn to create enum using strings, iterate over all enum values, get enum value and to perform reverse lookup to find enum by string parameter.

Java Custom Serialization using readObject() and writeObject()

We may need custom serialization in java in many cases. For example, we have legacy java classes that we are not willing to modify for any reason. There can be some design constraints as well. Or even simply, the class is expected to be changed in future releases which could …

RxJava Tutorial

RxJava 2.0 is open source extension to java for asynchronous programming by NetFlix. It is much closer to functional programming as seen in java 8 lambda expressions. The basic building blocks of reactive code are Observables and Subscribers. An Observable emits items; a Subscriber consumes those items.

Maven Parent and Child POM Example

Maven parent POM (or super POM) is used to structure the project to avoid redundancies or duplicate configurations using inheritance between pom files.

Maven Dependency Management

In this Maven tutorial,  learn about Maven dependency management, including external dependency, transitive dependency tree, excluding dependencies and version ranges. 1. What is Maven Dependency? In Maven, a dependency is just another archive—JAR, ZIP, and so on—which our current project needs in order to compile, build, test, and/or run. These project dependencies are collectively specified in …

Maven – POM File

POM (Project Object Model) is an XML file that contains information about the project and configuration details used by Maven to build the project i.e. sourcecode location, project dependencies etc. This file must be named as pom.xml and placed under root folder of project.

Maven – Settings File

Maven settings.xml file contains configurations that are not specific to a project, but are global in nature. It also contains information that is not meant to be distributed (e.g. passwords).

Difference between JUnit 5 an JUnit 4

JUnit 5 aims to adapt java 8 style of coding and to be more robust and flexible than JUnit 4. In this post, JUnit 5 vs JUnit 4, we will focus on some major differences between them.

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.