Java / Jakarta Messaging Service (JMS) on ...Microsoft podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #111 episode with Ashish Chhabria (@ashishc1) about:
algorithms, math in motion, passion with standards, JMS 2.0 on Microsoft's Azure Service Bus and JMS vs. Kafka
is available for

Java, Vaadin, Web and Vanilla Web podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #110 episode with Alejandro Duarte (@alejandro_du) about:
programming games and the "Apocalypse 2040", C, Java, Enterprise Java, Vaadin, Vaadin Web Components and vanilla Web Components
is available for

Joining Strings with Java 1.8+

The static String's method join, introduced in Java 1.8, joins a String array with a passed separator:

import static org.junit.jupiter.api.Assertions.assertEquals;
import org.junit.jupiter.api.Test;

public class StringJoinTest {
    public void joinStrings() {
        var commaSeparated = String.join(",", "hello", "world");
        assertEquals("hello,world", commaSeparated);

Extracting Fragments from JSON Documents with JSON-P

With Jakarta JSON Processing API (JSON-P) available in all Jakarta EE and MicroProfile runtimes, you can parse a JSON object:

import static org.junit.jupiter.api.Assertions.assertEquals;

import static javax.json.Json.*;
import javax.json.JsonObject;
import javax.json.JsonReader;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class JSONPPointerTest {

    JsonObject json;

    public void init() {
        var raw = this.getJSON();
        try(JsonReader reader = createReader(new StringReader(raw))){
            this.json = reader.readObject();

    String getJSON() {
        return """
                    "base": {
                        "cpu.systemLoadAverage": 4.14208984375,
                        "thread.count": 45,
                        "gc.time;name=G1 Young Generation": 16
                    "references":["MP metrics","JSON-P","rfc6901","Jakarta EE","microprofile"]
...and use a JSON Pointer (rfc6901) to extract values from nested objects:
    public void extractValueFromObject() {
        var pointer = createPointer("/base/thread.count");
        var fragment = pointer.getValue(this.json);
        assertEquals(createValue(45), fragment);
    } well as, JSON arrays:

    public void extractValueFromArray() {
        var pointer = createPointer("/references/1");
        var fragment = pointer.getValue(this.json);
        assertEquals(createValue("JSON-P"), fragment);

The JSON-P implementation already ships with all Jakarta EE 8 / Java EE 8 / MicroProfile runtimes. The single, test-scoped, dependency is only required to run the Unit Tests:


Also checkout: "Manipulating JsonObjects with JsonPatch"

Startup Hook / Initialization Logic with CDI

The Initialized qualifier is fired when a context is initialized, i.e. ready for use., and can be used to listen for the ApplicationScoped to be "ready".

Now you can use Initialized together with Observes to implement startup logic:

import javax.enterprise.context.ApplicationScoped;
import javax.enterprise.context.Initialized;
import javax.enterprise.event.Observes;

public class InitializerOnStart {

    public void onStart(@Observes @Initialized(ApplicationScoped.class) Object pointless) {
        System.out.println("InitializerOnStart.onStart() ");

...the same functionality with EJBs:

import javax.annotation.PostConstruct;
import javax.ejb.Singleton;
import javax.ejb.Startup;

public class InitializerOnStart {

    public void onStart() { }
(EJB example used in: A Java EE 7+ Alternative To EJB Timers)

Java, Agents, ODATA, Serverless and Cloud podcast

Subscribe to podcast via: spotify| iTunes| RSS

The #109 episode with Klaus Deissner (@kdeissner) about:
Java agents, semantic web, OData, ABAP and Java, serverless and Cloud Events
is available for

Run Java Source as Shell Scripts

JEP-330: "Launch Single-File Source-Code Programs" allows direct execution of Java source files without compilation. Now, you can also use Java as an interpreter program (instead of e.g. bash or zsh).

To execute the main method you will have to declare a specific shebang first (#!/[PATH]/bin/java --source [VERSION]), then a java class with a main method:

#!/usr/bin/java --source 11
public class App{
    public static void main(String ...args){
        System.out.println("hello, java (like script)");

The entire script can be now located, in an executable file with an arbitrary name like e.g.:

Executing: generates the following output: hello, java (like script)

Java: The First Monday of the Month

The following snippets calculates the next first Monday of the month:

import java.time.DayOfWeek;
import java.time.LocalDate;
import static java.time.temporal.TemporalAdjusters.*;

public class FirstMondayOfTheMonth {

    public static void main(String[] args) {
        var todayInAMonth =;
        var firstMondayOfTheMonth = todayInAMonth.
        System.out.printf("See you at next %s 8pm CET (UTC +1)",firstMondayOfTheMonth);

Because its Java, you don't even have to compile it (Java 11 / JEP-330).

Just run: java and you will get: "See you at next 2020-11-02 8pm CET (UTC +1)"

WebSockets, JWT, Monoliths, Quarkus, Jakarta EE, MicroProfile, WebComponents, JDKs--79th

The 79th live questions and answers show is available with the following topics:

"WebSocket authentication, viper code review, Quarkus and monoliths, automated container builds, portable datasources, Jakarta EE / MicroProfile configuration, hot reloading configuration, Redux with local and session store, Web Components styling, Quarkus and CDI, and various JDKs"

Any questions left? Ask now: and get the answers at the next

JAX-RS Error Serialization, Viper, Quarkus and Monoliths, Container Builds, WebSockets and JWT--or 79th

Topics, questions and topics ( for the 79th

  1. Code review feedback: error serialization, headers vs. body, threal local (...)
  2. Viper review -- extending the MicroProfile config
  3. What about using Quarkus for monoliths?
  4. Is it suitable to use for container builds?
  5. Portable installation of datasources
  6. Including build related information into an application
  7. How to convince your clients not to use a JS framework
  8. How to use bulma for all web components?
  9. WebSockets and JWT authentication

See you every first Monday of the month at 8pm CET (UTC+1:00). Show is also announced at:

Online Workshops
...the last 150 posts
...the last 10 comments