Java agents with Java 21
I wrote about the problems with Java agents in Notes and Domino 14.5.1. Well, there is a fix on its way...
I reported the issue to HCL Support as ticket CS1451588 which ended up in a fix that I have tried out. I applied the fix to my 14.5.1 FP1 client and it seems to work as expected. This snippet is Java 21 only:
import java.util.List;
import lotus.domino.*;
public class JavaAgent extends AgentBase {
public void NotesMain() {
try {
Session session = getSession();
AgentContext agentContext = session.getAgentContext();
System.out.println("Hello World!");
System.out.println("Database: " + agentContext.getCurrentDatabase().getTitle() + ", agent: " +agentContext.getCurrentAgent().getName());
var names = List.of("Anders", "Bent", "Claus");
System.out.println("Java 21 only. Show first list element: " + names.getFirst());
} catch(Exception e) {
e.printStackTrace();
}
}
}
It builds and when I run it this output is produced in the Java console - as expected:
Hello World!
Database: Dalsgaard's Contacts - YAML, agent: TestJvm
Java 21 only. Show first list element: Anders
This is great!
And if I look at the properties of the agent then it holds the right Java version (both source and target):


You can see the official defect article (KB0134216) and subscribe to be notified when the fix is officially integrated into a future release or Fix Pack.

