java

Java Performance on Linux vs Windows

Java is a cross-platform language, which means that Java applications can run on a variety of operating systems, including Linux and Windows. The performance of Java applications can depend on a variety of factors, including the specific implementation, the hardware and software environment, and the workload of the application. In general, Java applications tend to… read more »

Php Vs Java In Regards to Performance

The performance of PHP and Java can depend on a variety of factors, including the specific implementation, the hardware and software environment, and the workload of the application. In general, Java is considered to be a faster and more efficient language than PHP. Java’s performance benefits from the fact that it is a compiled language,… read more »

How to Create a Deadlock In Java with One Thread

A deadlock is a situation in computer programming where two or more processes are blocked, each waiting for the other to release a resource that they need in order to continue executing. As a result, all the processes remain blocked indefinitely and are unable to make further progress. In the context of multithreading, a deadlock… read more »

Java 8 Streams, Functions and Reductions Explained

There is a relatively simple challenge to extend the vowels in a string. Here is a way to do it in Java 8: In the above I’ve tried to make the code as short as possible while still ensuring it’s readable and conforming to the clean code rules. All of that could be written without… read more »

Reducing Streams in Java

Java 8 introduced streams, among other things, and one of my favourite features is the reduce() method. It combines a stream into a single method. Before Java 8 and streams, such a reduction had to be done with a loop like this: Now with Streams and reduce() it can be done as follows with a… read more »

Delete Files with Java 8

A friend asked me to help him with the following in Bash – delete all files but a whitelisted and use mix / max depth for directory traversal. It’s probably possible in Bash with some crazy find, grep, etc one-liner. But here’s how good it looks in Java 8 with streams, predicates, etc… With Java… read more »

Connect to Elasticsearch with Java and RestHighLevelClient

Connecting to Elasticsearch and executing queries is generally considered easy. In fact, in many cases a simple curl query like this one is all you need: Though, if you want something more than just finding all documents that contain mySearch (as per the example above), you may get lost in the abundance of options and… read more »

How to Change JVM Xms and Xmx for Tomcat on Windows

Changing Tomcat’s initial (Xms) and maximum (Xmx) memory turns out to be counter-intuitive on Windows, especially when Tomcat is installed as a service. That’s because when running under a service on Windows, Tomcat does not read initial runtime configure files such as setenv.bat (or setenv.sh for Linux) and thus you cannot define variables there. So… read more »

Sidebar