In May, I shared that JVM Weekly became a friend of Foojay.io - a community-driven platform for OpenJDK users, especially Java and Kotlin enthusiasts. Foojay.io connects OpenJDK “friends” with expert articles and community insights on trends, tools, and practices. This week, instead of weekly highlights, I selected a few articles from last month to share useful insights you can find in them.
Podcast: Proud Of Belgium: Devoxx, JobRunr, Timefold, OpenJDK Mobile, OpenJFX, Thymeleaf, htmx (#60)
Classically, we’ll start with a podcast—especially since this new edition is rather special.
The Proud Of Belgium podcast takes us on a journey through the world of Belgian innovations in Java. Frank Delporte, the familiar podcast host, meets with tools, libraries, and frameworks creators who have contributed significantly to the global Java community from Belgium. A disproportionate number of projects have emerged on this small stage (considering that the country is ten times smaller than Germany or my own Poland).
Among the interviewees:
Stephan Janssen - the organizer of Devoxx. It was in Belgium that Devoxx was born, which has since produced numerous spin-offs.
Ronald Dehuysser, the author of JobRunr , a task scheduling tool that makes it easier for developers to manage complex asynchronous processes.
Geoffrey De Smet from Timefold - a tool for solving planning problems that finds applications in many fields, from logistics to personnel management.
Johan Vos, who manages OpenJFX and OpenJDK Mobile, projects aimed at bringing Java to mobile platforms, thereby opening up new possibilities for developers.
Wim Deblauwe, author of works on template engines such as Thymeleaf and htmx, which facilitate the creating of dynamic Java-based web pages.
In the podcast, the interviewees share their experiences, both successes and challenges, and emphasize the importance of the Java community, its openness, and how it fosters talent development.
Simplified Web Application Development: Vaadin, HTMX, Vue.js, and Alpine.js
Just a week ago, I wrote about the renaissance of Java UI in different forms, and now Foojay.io seems to confirm this—several articles on this topic have appeared in just a month. Maybe this is a bit of a biased claim, as Nicolas Fränkel 🇺🇦🇬🇪 writes all the articles, but they still collectively provide an overview of approaches to UI in Java in 2024.
Let’s start with Vue.js, which of the three discussed by Nicolas is the most widespread. Vue.js originated in 2014 when its creator, Evan You, was working on projects at Google using AngularJS. He wanted to create a solution that combined the benefits of Angular's dynamic views with simplicity, without excessive complexity. From these experiences, Vue.js was born, which became especially popular in the open-source community (as Angular and React are corporate projects).
There’s also a high-quality documentary about the creation of Vue:
Vue.js also gained great popularity in Asia, especially in China, where it quickly became one of the most commonly used frontend frameworks. In China, Vue.js is used by many large technology companies, such as Alibaba, Tencent, and Xiaomi, who appreciate its lightness and performance. Its popularity in the region is also supported by the presence of numerous resources and documentation in Chinese, which facilitates learning and adaptation.
Let’s move on, a bit simpler. Alpine.js, the second project described by Nicolai, is a lightweight JavaScript library designed for adding interactivity to web pages in a simple and declarative way. It’s somewhat inspired by more popular frameworks like Vue.js or React but focuses on providing essential interactive functions with minimal code and configuration overhead. Alpine.js allows developers to introduce reactivity and manipulate the DOM without needing to write large amounts of JavaScript code—the whole system relies on HTML attributes like x-data, x-show, x-on, and x-bind. This enables developers to define the logic and behavior of components easily without requiring a full-fledged Single Page Application framework.
Intended for smaller applications, single pages, or components, Alpine.js provides flexibility in projects that only require simple user interactions without the need for large dependencies. Due to its lightness and approach similar to jQuery, Alpine.js is often used alongside traditional backend frameworks, like Spring Boot, Django, or Ruby on Rails, where frontend interactivity is needed but isn’t the main focus of the application.
A similar philosophy is followed by the last described project, htmx (HTML Over The Internet). It’s a lightweight JavaScript library that enables adding interactivity to HTML pages without requiring complex JavaScript code. It was designed to let developers use HTML attributes to create dynamic page elements that can respond to various events, like clicks, form submissions, or even scrolling.
With htmx, you can load content dynamically, perform AJAX requests, and handle data exchanges without needing to reload the page, making the application smoother and more responsive.
<table id="my-table">
<thead>
<tr>
<th>Name</th>
<th>Age</th>
</tr>
</thead>
<tbody>
<tr hx-get="/users/1" hx-target="#user-info" hx-swap="outerHTML">
<td>John Doe</td>
<td>30</td>
</tr>
<tr hx-get="/users/2" hx-target="#user-info" hx-swap="outerHTML">
<td>Jane Smith</td>
<td>25</td>
</tr>
</tbody>
</table>
In this example, we have a table with HTMX-enabled rows. When you click on a row, the hx-get attribute specifies that an HTTP GET request should be sent to the server to retrieve the user’s information.
The main strength of htmx lies in its simplicity and HTML-based approach, where the interaction code is declarative, and the logic remains in the HTML layer instead of JavaScript. Using attributes like hx-get, hx-post, and hx-trigger, you can precisely define when and how the interaction should occur, such as fetching data from the server or updating a part of the page. htmx supports different HTTP request types and allows for easy integration of backend functions with the frontend view, which can simplify the app structure and reduce the amount of JavaScript code required—similar to Thymeleaf. Not coincidentally, podcast guest Wim Deblauwe, an author on Thymeleaf, also wrote a book on htmx.
Each framework also received a full configuration description, including Maven build configurations, which isn’t always so obvious.
How to write Shebang Scripts in Java
I like posts like Java Tips #01 – Writing Shebang Scripts in Pure Java by A N M Bazlur Rahman. Simple, yet it allows us to look back at some historical issues that have been overcome.
A shebang (#!) sequence is a special line at the beginning of a script file that tells the operating system which interpreter or program should be used to execute the script. In the early days of Unix-like systems, scripts were written in shell languages like Bourne shell (sh) and C shell (csh). These scripts were executed by the shell interpreter, which looked for a special line at the beginning of the file starting with #! and then indicating the path to the interpreter that should be used to execute the script. This line is known as a shebang or hashbang.
When Java became popular in the 90s, programmers wanted to write scripts that could be executed directly from the command line without needing to explicitly start the JVM. To bypass this limitation, Java programmers used various tricks that took advantage of the fact that many Unix systems had an env command that could look up an executable file in the system PATH. Among the solutions were commands like #!/usr/bin/env java, special scripts that launched the JVM, or using a dedicated launcher.
Fortunately, these times are behind us, and as of Java 11, developers have access to shebang scripts that can be run directly from the shell, just like bash scripts. It’s a simple and efficient way to create command-line tools without needing external libraries.
The article Java Tips #01 – Writing Shebang Scripts in Pure Java describes step-by-step how to create a simple shebang script in Java, add functionality, and make it executable. It also includes tips for running shebang scripts from anywhere in the system.
If you’d like to learn more about the full functionality, Nicolai Parlog described it in detail when JDK 11 was released.
Easily Containerize Java Applications with Cloud Native Buildpacks
Now we move into more cloud-focused areas.
Buildpacks are tools that automate the process of building applications into container images, eliminating the need to manually write Dockerfiles. They analyze the application code and automatically select the necessary environment and dependencies, then package everything into a ready-to-use image. This process consists of two main phases: detection, during which the buildpack recognizes the type of application and requirements, and build, where the runtime environment is created and the final container image is assembled. This standardizes the build process and facilitates the transfer of applications between environments.
In the article Easily containerize Java applications with cloud native buildpacks by Grace Jansen, we learn how Cloud Native Buildpacks support efficient containerization of Java applications, simplifying and automating a process that would normally require knowledge of Docker and skills in creating Dockerfiles. Buildpacks recognize Java applications by identifying the presence of files like pom.xml or build.gradle and automatically configure the build and runtime environments. Using a builder mechanism, buildpacks can leverage ready-made components, such as base images (build image for building and run image for running the application), and OCI standards, which enable creating lightweight, portable images. The article also describes advanced mechanisms, such as rebasing (updating the base image without rebuilding the application), layered caching, and creating SBOMs (Software Bill of Materials), which supports efficiency as well as ensures compliance and security for applications.
Finally, Grace also introduces the Paketo Buildpacks project, built according to the Cloud Native Buildpacks specification, which provides production buildpacks for Java, including the option to run applications on Open Liberty or WebSphere Liberty.
Java Language Enhancements: Gatherers and Module Imports
And finally (well, almost) as usual, original JEP reviews. Miroslav (Miro) Wengner, author of articles on JEP-461 and JEP-476, describes improvements in the Java language introduced in JDK 23.
The first article, Exploring New Features in JDK 23: Module Design Pattern with JEP-476 discusses JEP 476: Module Import Declarations (Preview), introduced in JDK 23 to improve the module system. The article describes the evolution of JPMS, starting from challenges before Java 9 when managing isolated modules was difficult and often led to the so-called "classpath hell". With the introduction of the module system from Java 9, more transparent and secure use of modules became possible. Now, JEP-476 further simplifies the interaction between them, allowing the import of entire modules instead of individual classes, reducing the risk of unintentionally exposing the internal logic of modules. Instead of the rather dry format of the JEP itself, Miro’s readers will learn how to implement modules in practice and the benefits they bring for code clarity and project stability.
The second article, Exploring New Features in JDK 23: Gatherers upgrades pipeline design pattern JEP-461 describes the recently discussed Stream Gatherers. The introduction of Stream API in Java 8 allowed developers to create complex transformations in pipelines, but advanced operations were still challenging to implement. JEP-461 and Stream Gatherers expand the capabilities of intermediate operations directly within streams, eliminating the need to create hard-to-maintain Collectors that implement the entire transformation logic at the end. Gatherers enable easier work with pipelines, allowing for stream transformations with the internal state that is protected from external access. Readers will learn how Gatherers improve code clarity and security and make it easier to maintain and test streaming data transformations.
And “finally, finally”, a semi-personal note. In October, Foojay.io also published a positive review of Otavio Santana book, Mastering the Java Virtual Machine. This is particularly pleasing for me, as I had the opportunity to be its technical reviewer alongside already mentioned Frank Delport
PS: Foojay.io can boast arguably the best gadget (next to Red Hat’s red hat) in our little ecosystem - the build-your-own brick Duke. On Monday, we had a father-daughter bonding session assembling it, and I must say the result is truly remarkable and beautifully displayed.
Many thanks for adding my book review article under your JVM Weekly