Let’s continue from part 1 of this series, by looking at JEP 330, Launch Single-File Source-Code Programs, which is one of the new features introduced in the OpenJDK 11 release. This feature allows you to execute a Java source code file directly using the java interpreter.
The source code is compiled in memory and then executed by the interpreter, without producing a .class file on disk.
However, this feature is limited to code that resides in a single source file. You cannot add additional source files to be compiled in the same run.
Instead of starting up the JVM, loading a class and executing the code, you can run single Java source files. This feature is particularly useful…