Furthermore, there's ongoing work ([0] and related JEPs) to allow running single Java files without an enclosing class and the static main method:
void main() {
System.out.println("Hello, World!");
}
This is currently (as of JDK 24) under preview, so such a file needs to be run with "--enable-preview". E.g. $ java --enable-preview HelloWorld.java
Hello, World!
[0] https://openjdk.org/jeps/445