Running Single-File Java Source Code Without Compiling (Part 2)

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.

Mohamed Taman

Subscribe to foojay updates:

https://foojay.io/feed/
Copied to the clipboard