Configuring monitoring for Java Spring application using Prometheus and Grafana

Monitoring is a crucial aspect of modern software development. It’s essential to have visibility into your system state at any given moment. The choice of what to monitor is flexible and really depends on your team, as monitoring tools can accommodate custom metrics. Common metrics to consider include memory usage, I/O, error rates, and more. In this article, I will guide you through setting up an open-source monitoring stack using Prometheus and Grafana for your Java Spring Boot application....

July 17, 2024

Setting up Checkstyle linter for Java

Modern software development requires automated code checks to ensure that common code style standards are met. This is usually done by linters, which are available for many programming languages and usually built in a CI pipeline. What is a linter? A linter is a tool that analyzes your source code for potential errors, stylistic inconsistencies, and other issues that can affect code quality and maintainability. The name “linter” comes from the Unix utility lint, which was first released in the 1970s....

May 28, 2023

Java 17 LTS. Changes compared to Java 11

Oracle has released the new long-term support (LTS) version 17 of Java in September 2021. I’ve been working with it for more than a month and I’m now ready to outline all the major changes compared to Java 11, its previous LTS release. I deliberately do not compare it to 16 because most Java users work on LTS versions. That’s why it makes sense to have a list of all new features that were introduced in 12, 13, 14, 15, 16, and 17 versions....

October 21, 2021

Automate Java files formatting with IntelliJ IDEA

IntelliJ IDEA added one cool feature in their 2021.2 release: the ability to add actions when saving files. The most useful use-case is applying automatic reformatting and optimizing the imports. To enable that, go to Preferences -> Tools -> Actions on Save and select all required actions. Well-formatted code is a key factor in readability in large teams. Unless you are working alone on some pet project, you want consistency in code style across your codebase....

September 23, 2021

Parsing picture metadata in Java

If your system supports images, then most likely you need to extract some metadata from them on the back-end. Luckily for you, Drew Noakes has just the right library for that: metadata-extractor. Adding to dependencies Maven <dependency> <groupId>com.drewnoakes</groupId> <artifactId>metadata-extractor</artifactId> <version>2.16.0</version> </dependency> Gradle dependencies { implementation 'com.drewnoakes:metadata-extractor:2.16.0' } Example of fetching picture capture date and orientation public Date parseDateCaptured(byte[] pictureData) throws ImageProcessingException, IOException { var metadata = ImageMetadataReader.readMetadata(new ByteArrayInputStream(data)); var exifDirectory = metadata....

August 5, 2021

Java 16 release: non-LTS, incremental upgrade

Java 16 just got released. It is not a long-term support (LTS) version, so I don’t recommend upgrading your applications to this version, given LTS Java 17 will be available in late 2021. But I recommend at least getting familiar with the changelog since Java 17 will contain them as well. Most users won’t notice various internal improvements, so I’ve picked the following most interesting changes: Introduced Stream.toList() method which will simplify collecting the stream to list operation, which is very common and currently done via Stream....

March 20, 2021

SOLID Principles Explained

During the lifespan of software engineering, professionals created a lot of best practices and principles. Some of them were expressed as patterns, and some of them have evolved into abbreviations like DRY (Don’t Repeat Yourself). In this article, I will focus on SOLID: a set of 5 principles (mainly applicable to object-oriented programming) for articulating design issues and solutions. S - Single Responsibility Principle O - Open/Closed Principle L - Liskov’s Substitution Principle...

November 25, 2020

Java moves to native. Now with Project Leyden

Project Leyden Aims to Improve Java Startup Time Mark Reinhold, Java architect, recently proposed to start work on a new project to improve Java startup time and performance: Project Leyden. As we know, the best way to do that is to make Java apps run natively. GraalVM offers similar capabilities, but it is more about interoperability with other programming languages. I think the main goal of Project Leyden will be the ability to compile the application for a specific operating system, using its native libraries thus improving startup and runtime....

May 21, 2020

Reactive Java attracts more people

Spring: Blocking vs non-blocking: R2DBC vs JDBC and WebFlux vs Web MVC This recent article on blocking versus non-blocking Java performance proves the right direction in which Java slowly moves: reactive programming. New R2DBC driver (reactive successor to JDBC) is at its early stage of development (lack of JPA support), but it already shows significant performance benefits of non-blocking computations. Please keep in mind that it works only for high concurrent services....

May 6, 2020