I have 2 installations of Fedora — 39 as main and 40 as testing.
In Fedora 39 Java works (from command line java -jar).
In Fedora 40 with the same JAR Java fails with the message: “no x11 display variable was set, or no headful library support was found”. It says there is no DISPLAY variable, but id does exist and set to “:0” by system.