Best of Java — November 2024
- 1
- 2
InfoWorld·1y
Advanced programming with Java generics
This comprehensive guide dives into advanced programming with Java generics, covering key concepts like type inference, bounded and unbounded type parameters, type erasure, and wildcards. Learn how type parameters enhance type safety, flexibility, and readability in your Java code. Examples illustrate the use of generic methods, multiple bounds, and wildcards to create robust and flexible Java applications.
- 3
JetBrains·1y
Top Java Blogs for Experienced Programmers
A curated list of personal blogs from top Java experts, offering insights on topics like JVM performance tuning, Spring, JPA, Hibernate, and more. These blogs provide practical tips, tutorials, conference talks, and innovative solutions for building high-performance Java applications.
- 4
Inside Java·1y
Better Java Streams with Gatherers
The post introduces the Gatherers API added in JDK 24, designed to enhance the Java 8 Stream API intermediary operations. It offers a comprehensive step-by-step guide on using this API efficiently through various examples. Key topics include understanding intermediate and terminal operations, the working of internal mutable state, stream interruption, and parallelization. It also highlights advanced features like flat-mapping for element validation and mapMulti() to optimize stream object creation.
- 5
Baeldung·1y
Introduction to Lanterna
Lanterna is a Java library for building text-based user interfaces, similar to the Curses library, but in Java. It allows the creation of terminal UIs even in graphical environments using emulated terminals. This tutorial covers how to set up Lanterna, access and manipulate terminals, handle keyboard inputs, use the buffered screen API, and create text-based GUIs with various components.
- 6
Community Picks·1y
25 Reasons Why Financial Enterprise Companies Use Java
Financial enterprise companies heavily rely on Java due to its maturity, stability, and broad adoption. The Java Virtual Machine (JVM) is lauded for its robust engineering, making Java ideal for large-scale, mission-critical systems, especially in fintech where accuracy and reliability are essential. Java's strong, static typing, extensive standard libraries, and a large pool of experienced developers further cement its dominance in the financial sector.
- 7
Community Picks·1y
Java serialization: let's dig it up
Java serialization is the process of converting an object state into a byte sequence, enabling object transfer over networks or saving to a file. This post delves into the specifics of serialization using Java's Serializable and Externalizable interfaces, highlighting the requirements, methods, and nuances of each approach. Key points include how to serialize and deserialize objects, the importance of the no-argument constructor in non-serializable superclasses, and customizing serialization with the writeObject and readObject methods.
- 8
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.
- 9
Baeldung·1y
Introduction to JavaMelody
JavaMelody is a lightweight, open-source library designed to monitor Java applications, providing real-time statistics for performance analysis. It tracks various metrics including HTTP requests, SQL queries, CPU usage, and memory usage. Installation is straightforward, involving adding dependencies and configuring the web.xml file. It features optional centralized data collection, customizable trend charts, and error logging, with minimal performance overhead. Security considerations, such as role-based access, should be addressed when deploying in production environments.
- 10
InfoQ·1y
Optimizing Java Applications on Kubernetes: Beyond the Basics
Learn strategies for optimizing Java applications on Kubernetes beyond basic container management. The discussion includes reducing container image sizes for better security, improving JVM startup times with advanced techniques like Class Data Sharing, tuning JVM defaults for better performance, and employing Kubernetes features for more efficient resource allocation. Additionally, innovative concepts like A/B performance testing in production are explored to further enhance application performance and resource utilization.
- 11
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.
- 12
- 13
Foojay.io·1y
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.
- 14
Spring·1y
Bootiful Spring Boot 3.4: Spring Batch
Spring Batch 5.2 introduces various new features to enhance batch processing. Notable additions include multiple job repository implementations, such as a MongoDB-backed JobRepository and a resource-less JobRepository. The release improves support for Spring Data JPA and item readers/writers, including new Kotlin data class support and concurrent steps using blocking queues. The new features like CompositeItemReader and BlockingQueueItemWriter promise more robust and scalable batch processing by leveraging staged event-driven architecture and virtual threads in Java 21.
- 15
Baeldung·1y
Finding IP Address of a URL in Java
Learn how to find the IP address of a URL in Java through various methods, such as using the InetAddress class, socket connections, and third-party libraries like Apache Commons Lang and Google Guava. Each approach is illustrated with code examples and unit tests to ensure accuracy.
- 16
HappyCoders.eu·1y
Java Object Headers and Compressed OOPs
Java objects in memory include data and an Object Header, which contains the Mark Word and Class Word. These store essential information like the object's identity hash code, age, lock state, and reference to its class. Compressed OOPs allow addressing 32 GB of memory using 32-bit pointers by leveraging object alignment in memory. This trade-off between performance and memory space is enabled by default but can be disabled with a VM option. Future enhancements aim to further reduce object header size.
- 17
Awesome Java Newsletter·1y
Z Garbage Collector in Java
Java applications have diverse performance requirements, such as throughput, latency, and scalability. The Z Garbage Collector (ZGC) is designed to minimize pause times while efficiently managing large heap sizes. Unlike traditional garbage collectors that can cause significant application pauses, ZGC performs most of its work concurrently with the application, achieving minimal interruptions. This makes it ideal for high-demand environments like financial systems and large-scale cloud applications. The article includes a practical comparison between ZGC and G1 GC, showcasing ZGC's superior performance in maintaining low latency.
- 18
Baeldung·1y
How to Check if Two Boolean Values Are Equal
The post explores various ways to check for equality between boolean values in Java. It discusses direct comparison with the == operator, using the equals() method for Boolean objects, leveraging the XOR operator, utilizing Boolean.compare(), and employing Objects.equals() for null safety. Each method is explained with code examples, highlighting when and why to use each approach for efficient and readable code.
- 19
A Java geek·1y
Pseudo-Random Number Generators: From the Origins to Modern Algorithms
Pseudo-Random Number Generators (PRNGs) are critical tools in software development, simulating randomness through deterministic sequences. The evolution of PRNGs has advanced from early methods like linear congruential generators to sophisticated algorithms such as xoshiro, PCG, and LXM. Each PRNG offers different trade-offs in speed, memory usage, and statistical quality. High-quality PRNGs are essential for applications in simulations, game development, and machine learning, ensuring performance, correctness, and reliability.
- 20
Baeldung·1y
Java Date and Calendar: From Legacy to Modern Approaches
Handling dates and times in Java has evolved from using legacy classes like java.util.Date and java.util.Calendar to the modern java.time package introduced in Java 8. The new package addresses many issues found in the older classes, providing immutable, thread-safe classes with clear APIs and support for time zones. The post covers the history, benefits, and usage of modern date-time classes along with best practices for their implementation.
- 21
Baeldung·1y
Consuming Messages in Batch in Kafka Using @KafkaListener
The post discusses handling Kafka messages in batches using the @KafkaListener annotation from the Spring Kafka library. It covers the advantages of batch processing, such as increased system efficiency and fault tolerance, and presents a use case involving an IT infrastructure's KPIs. The article demonstrates the implementation of a basic listener and a batch-processing listener, explaining the configuration details and differences between the two approaches.
- 22
GOTO Conferences·1y97 Things Every Java Prog. Should Know • Trisha Gee & Kevlin Henney ft. Emily & Holly • GOTO 2024
The session discusses the book '97 Things Every Java Programmer Should Know,' highlighting its diverse contributions and themes. Authors Trisha Gee and Kevlin Henney present key insights alongside Emily and Holly, focusing on the importance of IDE usage, good unit tests, effective garbage collection, and approval testing. The book aims to provoke thought and conversation, offering contradictory perspectives and fostering discussions on various programming practices.
- 23
Baeldung·1y
Mockito Answer API: Returning Values Based on Parameters
This post discusses how to use Mockito's Answer API for testing role-based authentication services. It starts with mock creation using the mock() method, followed by method stubbing with thenAnswer(). The post explains how method invocation interception works in Mockito and provides examples of implementing the Answer API for different user roles in a content management system. Lastly, it outlines verifying the implementation through tests, ensuring proper role-based access.
- 24
- 25
Baeldung·1y
Testing the Main Class of a Spring Boot Application
Testing the main class of a Spring Boot application is crucial to ensure the application starts correctly. The post covers different strategies for testing, from basic context loading tests to mocking SpringApplication.run(), and explains how to handle application arguments and exclude the main class from code coverage. These methods help catch potential issues early and improve the reliability of the application startup process.