Best of Foojay.io — 2024
- 1
- 2
Foojay.io·1y
Task Schedulers in Java: Modern Alternatives to Quartz Scheduler
Quartz has been a long-standing job scheduling library in Java, but several modern alternatives like JobRunr and db-scheduler offer more developer-friendly APIs, better performance, and enhanced support for distributed environments. JobRunr stands out for its ease of use and built-in dashboard, while db-scheduler is appreciated for its simpler configuration. For broader workflow management, solutions like Temporal and Kestra are noteworthy for their resilient and low-code features.
- 3
Foojay.io·2y
Book Review: Mastering the Java Virtual Machine
Otávio Santana's 'Mastering the Java Virtual Machine' offers an in-depth exploration of JVM internals, combining nostalgic elements of Java programming with modern concepts. The book covers JVM architecture, performance optimization, class file structure, bytecode operations, memory management, JIT compilation, garbage collection, alternative JVMs like GraalVM, and advanced topics such as Java frameworks, reflection API, and code generation. It's an essential resource for Java developers aiming to improve their understanding and efficiency in Java development.
- 4
Foojay.io·1y
Front End Debugging Part 2: Console.log() to the Max
Explore advanced usage of `console.log()` for front-end debugging, including leveraging log levels, customizing output with CSS, stack tracing, assertions, and printing tables for clearer data visualization. Discover methods for copying objects to the clipboard, inspecting with console.dir(), counting function calls, organizing logs with groups, and utilizing Chrome-specific debugging features such as monitoring functions and events.
- 5
Foojay.io·2y
Java 23: What’s New?
Java 23 introduces significant changes, including the removal of the String Templates feature and the addition of several new preview features like JEP 455 for primitive types in patterns and JEP 467 for Markdown documentation comments. Other noteworthy updates include the deprecation of many methods in sun.misc.Unsafe for safer alternatives and the ZGC garbage collector's generational mode becoming the default. Features like the Class-File API, Vector API, and Stream Gatherers remain in preview. The version also includes various improvements to the JDK and internal changes aimed at performance and security.
- 6
Foojay.io·1y
How Organizations Became Stuck on Outdated Java Versions
Organizations often remain on outdated Java versions like Java 8 due to management resistance, high costs of upgrading, compatibility issues with existing systems, and the additional effort required to refactor code and update libraries. Despite these challenges, using up-to-date Java versions offers significant benefits, including improved performance, security, and developer productivity. The article discusses real-world examples, both of organizations stuck on older versions and successful upgrades, aiming to encourage decision-makers to consider updating their Java runtime environments.
- 7
Foojay.io·2y
Java: Demystifying The Stream API
The post explains the Java Stream API, which is a collection of functions that enable a more declarative and functional way of processing data collections. Key operations such as map, filter, and reduce are discussed, with examples of their use. The post also covers intermediate and terminal operations, parallel processing with streams, and performance considerations compared to traditional for loops. Tips for error handling and best practices for using streams are provided.
- 8
Foojay.io·2y
Spring Boot: Java Template Engine (JTE)
The Java Template Engine (JTE) is a new addition to the Spring Initializer Ecosystem, designed for developing user interface applications using Java syntax within Spring Boot applications. JTE provides a user-friendly syntax, supports plain Java or Kotlin expressions, and performs context-aware HTML escaping at compile time. It integrates with frameworks like Spring MVC, Ktor, Micronaut, and more. Instructions for Maven and Gradle integration, along with a practical Spring Boot example, are included to demonstrate JTE's implementation.
- 9
Foojay.io·1y
Run a Java Lambda Function From a Docker image
Learn how to package and deploy a Java Serverless function using Docker and AWS's new container support. The guide includes step-by-step instructions for setting up a Maven project, creating a Docker image, configuring AWS infrastructure (ECR, IAM roles, policies), and deploying the Lambda function. It also covers both local and remote testing of the deployed function.
- 10
Foojay.io·2y
A Fresh Look at Embedded Java
Java, known for its 'Write Once, Run Anywhere' philosophy, continues to be a powerful choice for embedded systems ranging from in-car infotainment to home automation and medical devices. The language offers energy efficiency, developer productivity, and a stable runtime, with Azul providing builds of OpenJDK optimized for various platforms. Key solutions like CRaM and CRaC help reduce application startup time, making Java an ideal choice for rapid deployment scenarios. Azul also ensures long-term support, security updates, and legal protection for users of their Java runtime builds.
- 11
Foojay.io·2y
Effective Java Logging
Effective logging is crucial for Java applications, especially in production environments where it assists in debugging, monitoring, and incident response. This guide discusses best practices for using SLF4J and Logback to achieve efficient, maintainable, and informative logging. Key benefits include improved observability, faster troubleshooting, enhanced incident response, and compliance. The guide also covers critical topics such as using appropriate log levels, logging meaningful messages, employing placeholders for dynamic content, asynchronous logging, securing sensitive information, and integrating logs with monitoring tools.
- 12
Foojay.io·2y
Java: Functional Programming f(x) – Part2
This post discusses the important features of functional programming in Java, including lambda expressions, method references, functional interfaces, and the streams API. It highlights the significance of lambda expressions in simplifying code and provides examples of their usage.
- 13
Foojay.io·2y
Building a Simple Home Assistant using Langchain4j and Raspberry Pi
Building a smart home assistant using Langchain4j and Raspberry Pi has become more accessible than ever before. With the help of LLMs and an internet connection, anyone can create a Generative AI-powered app in minutes. This article demonstrates how to build a simple home assistant that can converse with the user, provide news, analyze the environment, toggle a smart strip on, and answer questions using Langchain4j, Raspberry Pi, and external APIs.
- 14
- 15
Foojay.io·2y
Builder Pattern Simplicity with JEP-455 Primitive Types
JDK 23 introduces JEP-455, which simplifies the usage of primitive types within the builder design pattern. This enhancement reduces the necessity of verbose typecasting, making the code more readable and maintainable. The builder pattern is highlighted as being more flexible and testable compared to the factory pattern, especially with the advanced operations facilitated by JEP-455. The local variable type inference provided by JEP-286 also enhances code clarity during the object creation process.
- 16
Foojay.io·2y
SQL Query Optimization: How to Identify and Optimize Slow SQL Queries
This post provides insights and real-life examples on how to identify and optimize slow SQL queries. It discusses challenges in finding slow SQL queries, the benefits of Continuous Feedback in identifying query issues, and various methods for optimizing SQL queries.
- 17
Foojay.io·2y
Crafting Your Own Railway Display with Java!
Create your own railway information display using Java, SpringBoot, and Vaadin. The project utilizes the Nederlandse Spoorwegen (NS) APIs for live data, and runs on a Raspberry Pi 4. The guide includes steps for setting up the backend with Jakarta EE, building the frontend with Vaadin Grid, and configuring the Raspberry Pi. The project demonstrates the use of server push updates and customizing UI components.
- 18
Foojay.io·2y
Null object pattern to avoid null pointer exception with JEP-455
JDK 23 introduces critical enhancements with JEP-455, which extends pattern matching to include primitive types in switch and instanceof statements. This update aligns Java more closely with functional programming paradigms. The null object pattern is highlighted as a method to avoid null pointer exceptions, illustrated using a vehicle sensor cache scenario. These changes promote better code maintainability and improved program execution speed.
- 19
Foojay.io·2y
Interview with a Java Champion: Reflections on a Storied Career and Insights for the Next Generation
A seasoned developer with over two decades of experience, Ben Evans shares his journey from first learning Java in 1998 to becoming deeply involved in the Java community. He reflects on the evolution of Java, the importance of community, and the challenges new developers face today. Ben also provides insights into the process of writing and revising technical books, highlighting the continuous changes in software trends and the enduring relevance of fundamental skills.
- 20
Foojay.io·2y
Spring: Internals of @ComponentScan
The @ComponentScan annotation in Spring, located within the org.springframework.context.annotation package, helps automatically detect beans in a Spring application. It can identify classes annotated with stereotypes like @Configuration, @Component, @Service, @Controller, and @Repository. The annotation can be used with or without parameters, such as basePackageClasses() or basePackages(), to specify scanning packages. It essentially replaces the XML tag <context:component-scan/> and includes various attributes for customizing the component scanning process, like nameGenerator, scopeResolver, scopedProxy, useDefaultFilters, includeFilters, and excludeFilters.
- 21
Foojay.io·2y
The Best Way to Handle Phone Numbers
Processing phone numbers can be simplified using Google's libphonenumber library. This library helps in parsing, formatting, and validating international phone numbers. It's recommended to store the country code and national number separately in a database for better handling.
- 22
- 23
Foojay.io·2y
Easily containerize Java applications with cloud native buildpacks
Cloud Native Buildpacks offer a streamlined way to containerize Java applications, converting source code into secure, efficient, production-ready container images. The process involves two phases—detect and build—leveraging pre-configured buildpacks and builders to automate much of the setup, ensuring consistency, portability, flexibility, automation, and security. These buildpacks support multiple languages and advanced features like rebasing and caching, making them a versatile tool for developers. Paketo Buildpacks, adhering to this specification, simplify the process further by providing ready-to-use buildpacks for popular frameworks.
- 24
Foojay.io·2y
JDK 23: Factory Pattern with Flexible Constructor Bodies
JDK 23 introduces a new preview feature, JEP-482: Flexible Constructor Bodies, aimed at enhancing creational design patterns. This feature allows validation and handling of constructor arguments before calling `super(...)` or `this(...)`, improving code maintainability and reducing boilerplate. Examples demonstrate how this flexibility supports more functional coding styles, simplifying object creation and improving efficiency.
- 25
Foojay.io·2y
Structured Concurrency is More Than ShutdownOnFailure
Since Java 21, structured concurrency has been introduced as a preview feature to manage parallel sub-tasks within a given scope. While common use cases focus on `ShutdownOnSuccess` and `ShutdownOnFailure`, the 'Virtually' project extends capabilities with `EnhancedTaskScope`. This includes throttling to limit simultaneous tasks, circuit breaker mechanisms, default values upon task failure, critical task prioritization, and efficient list conversion using structured concurrency. These enhancements help manage high load and failure scenarios more effectively, leveraging the power of Java's virtual threads.