In Introducing Unnamed Classes and Simplified Main Methods in Java
I ended up comparing the performance of direct execution of a java source file with main method by skipping the explicit
javac step with the normal build and execution process javac X; java X (some assumptions made
about the classpath excluded). I then went on to use Graal to compile the simple app into native code.
The performance aspect I was looking at was start up and the simple CLI that did some stuff and then
exited provided a reasonable exercise.
Java has long been known for its verbosity, especially when it comes to writing simple scripts or
small programs. With Java 21’s introduction of simplified main methods, developers can now
write more concise and readable entry points for their applications. The feature is primarily to
teach Java by just making it easier to start.
Sometimes you might need to execute a Java CLI from Gradle. I was playing around with
Playwright and wanted to use the codegen tool to gen java from recording
a surfing session. There are instructions for making
this work with Maven but not Gradle. The trick with Gradle though is to create a new task in groovy and
then exec that with the gradle wrapper.