Java XPath NamespaceContext – NameSpace Resolution Example
In java example, we will learn xpath namespace resolution into an XML file using NamespaceContext which has namespace declarations and their usages.
In java example, we will learn xpath namespace resolution into an XML file using NamespaceContext which has namespace declarations and their usages.
This exception you may face while starting jetty server packaged inside your dropwizard REST application uber jar.
Learn to convert OutputStream to InputStream in Java using ByteArrayInputStream and Java NIO Files Channel API.
Learn to add username/password based authentication and role based authorization capabilities into REST APIs using basic authentication.
Learn to work with CSV files in Python. Python language contains the csv module which has classes to read and write data in the CSV format.
DropWizard health check is implemented by extending the HealthCheck class and returning Result.healthy() if everything is alright and Result.unhealthy() if something is not working – as expected.
Dropwizard supports both Apache HttpClient and Jersey Client. Learn to inject client to the REST controller and inject custom properties.
In this step-by-step Dropwizard tutorial, learn to build a basic CRUD (Create, Read, Update, Delete) application having REST APIs to perform operations.
You may get this error when you have incompatible version of maven and it’s maven shade plugin. Fixing version number mismatch will solve the issue.
Learn to use the Maven Shade plugin for packaging a java application with its dependencies into a fat jar or uber jar.
The gradle init command generate a build.gradle file which you can now use to run all your builds using gradle commands.
Gradle tutorial learn to import and install gradle plugin for eclipse either using eclipse marketplace and update manager.
Learn about how Gradle is different from other build automation tools, and then we will see one simple example of installing and using Gradle.
Learn to read CSV file in Java and write data to CSV files. Super CSV file is opensource library to support read and write operations on CSV files.
In this Java puzzle, we have a series of numbers and exactly one number is missing. We have to write a program to find the missing number.
Jasmine tutorial to learn setup instructions, jasmine suite and specs, setup and teardown methods, describe blocks, jasmine matchers, jasmine spies etc.
Learn about Localization and Internationalization with Locale. Learn to create Locale objects and use them for formatting dates and messages.
Java examples of unzipping and extracting the zip file using java.util.zip package and apache commons compress module.
To find the current working directory for any Java application, we can use System.getProperty(“user.dir”) or Paths.get().toAbsolutePath().
In this example, we will learn to serialize the java objects into XML files and then de-serialize them back to the original java objects.
Knowing the difference between Externalizable vs Serializable is important in two aspects, one – if could be asked as an interview question, two – you can use the knowledge to make better informed decision for performance improvement for applying serialization into your application.
You can achieve more efficient serialization by implementing Externalizable interface and overriding it’s methods writeExternal() and readExternal().
Learn to use java.util.Random, Math.random(), SecureRandom and ThreadLocalRandom to generate random numbers based on your application requirements.
Use given syntax examples for setting CLASSPATH for any java application runtime, in windows and linux environments.
This Log4j2 example will help you in configuring log4j2.xml file with HTMLLayout. The HTMLLayout generates an HTML page and adds each log statement to a row in a table.
Log4j2 ThreadContext allows you to fish tag the log statements with multiple unique tags to analyze logs while diagnose a problem in runtime.
Given log4j2 conversion patterns are for reference so that you and me don’t waste time to build these patterns everytime we are creating/editing log4j configuration files.
Learn some recommended ways to configure Log4j2 – specific to junit testcases and different from used in production.
Java examples of reading a file from the resources folder from a jar file, war file, spring application or the development environment.
Apache Log4j 2 is an upgrade to Log4j 1.x that provides significant improvements over its predecessor such as performance improvement, automatic reloading of modified configuration files, Java 8 lambda support and custom log levels. In addition to XML and properties files, Log4j2 can be configured using JSON also. 1. Log4j2 …
Log4j2 properties tutorial. Learn to configure log4j2.properties file to output to console, rolling files etc. Learn log4j2 appenders, levels and patterns.
Learn log4j2 XML configuration example to configure console appender, rolling file appender and multiple appenders and bootstrapping Logger.
Spring mvc multiple file upload with progress bar example to upload multipart requests for files and save files to upload directory on server.
I encountered this exception while building spring MVC file upload example. The error stacktrace looks like this: Solution You have incorrect version of apache commons-fileupload. To solve this error, you correct version 1.2.1. This will solve your error. Happy Learning !!
Spring MVC file upload example. Learn to upload single or multiple files to a configured upload directory using CommonsMultipartResolver.
In this Spring Boot MVC download file controller example, learn to create the handler method and prevent hot linking of the download URLs.
Over last 9 years, I have found these top 10 java websites most useful for me. I do not intend to rank them for their popularity, but how much useful they have been for me in my career.
In this Java OOPs concepts tutorial, we will learn four major object oriented principles– abstraction, encapsulation, inheritance, and polymorphism. They are also known as four pillars of the object oriented programming paradigm.
We may be asked to write a program to calculate factorial during coding exercises in Java interviews. This always better to have an idea of how to build such a factorial program. 1. What is Factorial? The factorial of a number is the product of all positive descending integers up to …
BlockingQueue is excellent when you want to skip the complexity involved in wait–notify statements. This BlockingQueue can be used to solve the producer-consumer problem as well as given blow example. As this problem is well known to every programmer, I am not going in detail of problem description. How BlockingQueue …
Learn different techniques to iterate over a Java Collection (List, Set and Map) using for-loop, enhanced for-loop, Iterator and Java Stream.
Learn to convert a string to date in Java 8 using the new date time API classes such as LocalDate, LocalDateTime, ZonedDateTime and DateTimeFormatter. 1. Convert string to date in ISO8601 format By default, java dates are in ISO8601 format, so if you have any string which represents a date …
Let’s look at a few Java examples of conversions between decimal, binary, octal, and hexadecimal. All examples use native Java APIs without adding any more complexity.
Learn to write Java programs to reverse a String. Learn how to reverse the characters of a string and then how to reverse the words.
Learn about the lifecycle of a Thread in Java, and how the state transitions happen between different states of the Thread by JVM and OS.
Learn to join string array with delimiter to produce single string. Use listed java example to convert list of strings or array of strings to single string.
Learn to configure and use SelectableEntityFilteringFeature for implementing the entity data filtering in Jersey controlled from the clients.
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.