Hot to solve the “Too many Open Files” error in Java applications

This tutorial will discuss how to fix one of the most common errors for Java applications: “Too many open files“. The error Java IOException “Too many open files” can happen on high-load servers and it means that a process has opened too many files (file descriptors) and cannot open new ones. In Linux, the maximum … Read more

Writing high performance Java HTTP Client applications

This tutorial provides a detailed exposere on writing high performance Java HTTP Client with Apache HTTP Client library. Out of the box, Apache HttpClient is configured to provide high reliability and standards compliance rather than raw performance. There are however several configuration tweaks and optimization techniques which can significantly improve the performance of applications using … Read more

How to solve java.lang.OutOfMemoryError: Compressed class space error

This article discusses how to solve the error “java.lang.OutOfMemoryError: Compressed class space error” which is an OutOfMemory error that can pop up on a 64-bit platform. Starting with Java 1.8, loaded classes are confined to a native space called the “Compressed Class Metadata Space” or CCMS. The default size for the Compressed Class Metadata Space … Read more

How to configure the HeapDumpOnOutOfMemoryError parameter on JBoss EAP or WildFly

How to configure the HeapDumpOnOutOfMemoryError parameter on JBoss EAP or WildFly ? It’s pretty simple. The -XX:+HeapDumpOnOutOfMemoryError command-line option tells the HotSpot VM to generate a heap dump when an allocation from the Java heap or the permanent generation cannot be satisfied. Just like any other JVM parameters, it can be added in the standalone.conf … Read more

How to measure the time spent on methods execution in Java

In this tutorial we will show how to measure the time spent on the execution of a Java method by using Byteman tool. There are several tools or product which can trace the execution of Java methods and calculate how much time you are spending in the single methods of your application. This is a … Read more

Java scripting with JBang

JBang is a scripting tool which allows to run Java application with minimal set up, without the need of having a project configuration. In this tutorial we will learn how to use it to run a simple Java application and then we will be looking at a more complex example, which starts a Quarkus application. … Read more

4 ways to initialize an Array in Java

This article discusses about array initialization in Java, showing multiple ways to initialize an Array, some of them you probably don’t know! Basic Array Initialization in Java First of all, let’s learn how to declare an Array: String array[]; So you basically specify the datatype and the declared variable name. Mind it, declaring an array … Read more

Troubleshooting OutOfMemoryError: Direct buffer memory

The java.nio.DirectByteBuffer class is special implementation of java.nio.ByteBuffer that has no byte[] laying underneath. The main feature of DirectByteBuffer is that JVM will try to natively work on allocated memory without any additional buffering so operations performed on it may be faster then those performed on ByteBuffers with arrays lying underneath. We can allocate such … Read more

Simple strategies to test your Java applications with LDAP

LDAP is commonly used in Security realms as a source of authentication and authorization information. This tutorial will teach you two simple strategies for starting an LDAP Server in minutes in order to secure your Enterprise applications. Option 1: Use an Embedded LDAP Server The first example is using an embedded ApacheDS LDAP server with … Read more

How to find out which JAXB implementation is used in your code

When using WildFly or JBoss EAP, the JAXB implementation is defined by the following specification in module.xml: <module name=”javax.xml.bind.api” xmlns=”urn:jboss:module:1.7″> <dependencies> <module name=”javax.activation.api” export=”true”/> <module name=””/> <module name=”com.sun.xml.bind” services=”import”/> <module name=”javax.api”/> </dependencies> <resources> <resource-root path=”jboss-jaxb-api_2.3_spec-1.0.1.Final-redhat-1.jar”/> </resources> </module>  In order to check the actual JAXB implementation, you can just create a new Instance of JAXBContext and … Read more