Slow MySQL query performance is all too common. Of course it is. A good way to go is, naturally, a dedicated profiler that actually understands the ins and outs of MySQL.
The Jet Profiler was built for MySQL only , so it can do things like real-time query performance, focus on most used tables or most frequent queries, quickly identify performance issues and basically help you optimize your queries.
Critically, it has very minimal impact on your server's performance, with most of the profiling work done separately - so it needs no server changes, agents or separate services.
Basically, you install the desktop application, connect to your MySQL server , hit the record button, and you'll have results within minutes:
out the Profiler
Accelerate Your Jakarta EE Development with Payara Server!
With best-in-class guides and documentation, Payara essentially simplifies deployment to diverse infrastructures.
Beyond that, it provides intelligent insights and actions to optimize Jakarta EE applications.
The goal is to apply an opinionated approach to get to what's essential for mission-critical applications - really solid scalability, availability, security, and long-term support:
A quick guide to materially improve your tests with Junit 5:
>> The Junit 5 handbookWorking on getting your persistence layer right with Spring?
Do JSON right with Jackson
Get the most out of the Apache HTTP Client
Get Started with Apache Maven:
Explore Spring Boot 3 and Spring 6 in-depth through building a full REST API with the framework:
Get started with Spring and Spring Boot, through the reference Learn Spring course:
Building a REST API with Spring?
The AI Assistant to boost Boost your productivity writing unit tests - Machinet AI .
AI is all the rage these days, but for very good reason. The
highly practical coding companion, you'll get the power of
AI-assisted coding and
automated unit test generation
.
Machinet's
Unit Test AI Agent
utilizes your own project
context to create meaningful unit tests that intelligently aligns
with the behavior of the code.
And, the
AI Chat
crafts code and fixes errors with ease,
like a helpful sidekick.
Simplify Your Coding Journey with Machinet AI :
Get non-trivial analysis (and trivial, too!) suggested right inside your IDE or Git platform so you can code smart, create more value, and stay confident when you push.
Get CodiumAI for free and become part of a community of over 280,000 developers who are already experiencing improved and quicker coding.
Write code that works the way you meant it to:
CodiumAI. Meaningful Code Tests for Busy Devs
Looking for the ideal Linux distro for running modern Spring apps in the cloud?
Meet Alpaquita Linux : lightweight, secure, and powerful enough to handle heavy workloads.
This distro is specifically designed for running Java apps . It builds upon Alpine and features significant enhancements to excel in high-density container environments while meeting enterprise-grade security standards.
Specifically, the container image size is ~30% smaller than standard options, and it consumes up to 30% less RAM:
Alpaquita Containers now.
Yes, Spring Security can be complex, from the more advanced functionality within the Core to the deep OAuth support in the framework.
I built the security material as two full courses - Core and OAuth , to get practical with these more complex scenarios. We explore when and how to use each feature and code through it on the backing project .
You can explore the course here:
Slow MySQL query performance is all too common. Of course it is. A good way to go is, naturally, a dedicated profiler that actually understands the ins and outs of MySQL.
The Jet Profiler was built for MySQL only , so it can do things like real-time query performance, focus on most used tables or most frequent queries, quickly identify performance issues and basically help you optimize your queries.
Critically, it has very minimal impact on your server's performance, with most of the profiling work done separately - so it needs no server changes, agents or separate services.
Basically, you install the desktop application, connect to your MySQL server , hit the record button, and you'll have results within minutes:
out the Profiler
Spring Data JPA is a great way to handle the complexity of JPA with the powerful simplicity of Spring Boot .
Get started with Spring Data JPA through the guided reference course:
Just published a deep dive into building a relevance-focused search with MongoDB. More or less out of the box:
Creating PDFs is actually surprisingly hard. When we first tried, none of the existing PDF libraries met our needs. So we made DocRaptor for ourselves and later launched it as one of the first HTML-to-PDF APIs.
We think DocRaptor is the fastest and most scalable way to make PDFs , especially high-quality or complex PDFs. And as developers ourselves, we love good documentation, no-account trial keys, and an easy setup process.
>> Try DocRaptor's HTML-to-PDF Java Client (No Signup Required)
Get started with Spring and Spring Boot, through the Learn Spring course:
>> CHECK OUT THE COURSE1. Overview
Temporary directories come in handy when we need to create a set of files that we can later discard. When we create temporary directories, we can delegate to the operating system where to put them or specify ourselves where we want to place them.
In this short tutorial, we’ll learn how to create temporary directories in Java using different APIs and approaches . All the examples in this tutorial will be performed using plain Java 7+, Guava , and Apache Commons IO .
2. Delegate to the Operating System
One of the most popular approaches used to create temporary directories is to delegate the destination to the underlying operating system. The location is given by the java.io.tmpdir property, and every operating system has its own structure and cleanup routines.
In plain Java, we create a directory by specifying the prefix we want the directory to take:
String tmpdir = Files.createTempDirectory("tmpDirPrefix").toFile().getAbsolutePath();
String tmpDirsLocation = System.getProperty("java.io.tmpdir");
assertThat(tmpdir).startsWith(tmpDirsLocation);
Using Guava, the process is similar, but we can’t specify how we want to prefix our directory:
String tmpdir = Files.createTempDir().getAbsolutePath();
String tmpDirsLocation = System.getProperty("java.io.tmpdir");
assertThat(tmpdir).startsWith(tmpDirsLocation);
Apache Commons IO doesn’t provide a way to create temporary directories. It provides a wrapper to get the operating system temporary directory, and then, it’s up to us to do the rest:
String tmpDirsLocation = System.getProperty("java.io.tmpdir");
Path path = Paths.get(FileUtils.getTempDirectory().getAbsolutePath(), UUID.randomUUID().toString());
String tmpdir = Files.createDirectories(path).toFile().getAbsolutePath();
assertThat(tmpdir).startsWith(tmpDirsLocation);
In order to avoid name clashes with existing directories, we use UUID.randomUUID() to create a directory with a random name.
3. Specifying the Location
Sometimes we need to specify where we want to create our temporary directory. A good example is during a Maven build. Since we already have a “temporary” build target directory, we can make use of that directory to place temporary directories our build might need:
Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix");
assertThat(tmpdir.toFile().getPath()).startsWith("target");
Both Guava and Apache Commons IO lack methods to create temporary directories at specific locations.
It’s worth noting that the target directory can be different depending on the build configuration . One way to make it bullet-proof is to pass the target directory location to the JVM running the test.
As the operating system isn’t taking care of the cleanup, we can make use of File.deleteOnExit() :
tmpdir.toFile().deleteOnExit();
This way, the file is deleted once the JVM terminates, but only if the termination is graceful .
4. Using Different File Attributes
Like any other file or directory, it’s possible to specify file attributes upon the creation of a temporary directory. So, if we want to create a temporary directory that can only be read by the user that creates it, we can specify the set of attributes that will accomplish that:
FileAttribute<Set> attrs = PosixFilePermissions.asFileAttribute(
PosixFilePermissions.fromString("r--------"));
Path tmpdir = Files.createTempDirectory(Paths.get("target"), "tmpDirPrefix", attrs);
assertThat(tmpdir.toFile().getPath()).startsWith("target");
assertThat(tmpdir.toFile().canWrite()).isFalse();
As expected, Guava and Apache Commons IO do not provide a way to specify the attributes when creating temporary directories.
It’s also worth noting that the previous example assumes we are under a Posix Compliant Filesystem such as Unix or macOS.
More information about file attributes can be found in our Guide to NIO2 File Attribute APIs .
5. Conclusion
In this short tutorial, we explored how to create temporary directories in plain Java 7+, Guava, and Apache Commons IO. We saw that plain Java is the most flexible way to create temporary directories as it offers a wider range of possibilities while keeping the verbosity to a minimum.
As usual, all the source code for this tutorial is available over on GitHub .
Can Jakarta EE be used to develop microservices? The answer is a resounding ‘yes’!
Demystifying Microservices for Jakarta EE & Java EE Developers
Slow MySQL query performance is all too common. Of course it is.
The Jet Profiler was built entirely for MySQL , so it's fine-tuned for it and does advanced everything with relaly minimal impact and no server changes.
out the Profiler
Explore the secure, reliable, and high-performance Test Execution Cloud built for scale. Right in your IDE:
CodiumAI. Meaningful Code Tests for Busy Devs
Basically, write code that works the way you meant it to.
AI is all the rage these days, but for very good reason. The
highly practical coding companion, you'll get the power of
AI-assisted coding and
automated unit test generation
.
Machinet's
Unit Test AI Agent
utilizes your own project
context to create meaningful unit tests that intelligently aligns
with the behavior of the code.
Simplify Your Coding Journey with Machinet AI :
Get started with Spring and Spring Boot, through the Learn Spring course:
>> CHECK OUT THE COURSEwith Spring ?