Scenario: Your application log displays the error message “Too many Open Files“. As a result, application requests are failing and you need to restart the application. In some cases, you also need to reboot your machine. In this article we will discuss File handling best practices and how to prevent File leaks in Java with proper resource management.
Java
Java Lambda Expressions Examples
Lambda expressions in Java are a concise way to represent anonymous functions or “function literals.” They are primarily used to implement functional interfaces, which are interfaces with a single abstract method. Let’s dive into some examples.
How to configure the HeapDumpOnOutOfMemoryError parameter in Java
This article will teach you what is the usage of the HeapDumpOnOutOfMemoryError JVM parameter and how to configure it on an application server such as JBoss EAP or WildFly. HeapDumpOnOutOfMemoryError made simple The JVM parameter “-XX:+HeapDumpOnOutOfMemoryError” captures OutOfMemoryError instances that occur due to memory exhaustion in the Java heap space. When the Java Virtual Machine … Read more
How to Fix the HTTP 415 “Unsupported Media Type” Error with JSON
If you’re a developer who has worked with web APIs, you might have come across the HTTP 415 “Unsupported Media Type” error. This error occurs when the server doesn’t support the media type that’s being used in the request. In this tutorial, we’ll discuss one common cause of the HTTP 415 error and how to fix it.
How to catch multiple Exceptions in Java
When working with Java, it’s common to encounter situations where you need to handle multiple exceptions. Fortunately, Java provides a simple and efficient way to do this using the catch block. In this tutorial, we’ll explore how to catch multiple exceptions in Java, along with some tips and code snippets to help you get started.
Java Finally Block – When it is not executed ?
The finally block in Java is used to define a section of code that will always be executed, regardless of whether an exception is thrown or caught. However, there are certain conditions under which the finally block may not execute. In this tutorial, we’ll explore these conditions and provide some code snippets to illustrate them. Hint: read it through as this is a common interview question!
8 Things you can do with JBang but you can’t with Shell
Using Java as scripting language has become a popular option in the last few years thanks to the JShell tool. In this article we will learn how the JBang scripting tool can take your Java scripting power at another level.
Two ways to read a File in a String with Java
Do you need to read a File into a String in Java ? This article will show two simple ways to achieve it. By the end of it, you will also learn the differences between each solution. Solution #1 Use Files.readAllBytes The first solution, which reads a file into an array of Bytes, uses the … Read more
How to solve the error “invalid target release: 17”
This article shows how to fix the compilation issue that you can hit when the target Java release specified in your Maven configuration does not match the version of Java installed on your system. For example, your environment uses Java 11 but your Maven configuration requires Java 17.
How to list Maven local artifacts using JBang
Listing the available artifacts in your Maven local repository generally requires a Maven project. In this article we will show how to create a simple JBang script to list all dependencies for an artifact in your local Maven repository.