Mohamed Taman (@_tamanm) is CEO/Owner at SiriusX Innovations, Chief Architect, Java Champion, Oracle Groundbreaker Ambassador, Jakarta EE Ambassador, JCP, Technology Geek, International Speaker, and Author.
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
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 for someone new to the language who wants to try out simple programs, you get a great beginner’s learning toolset.
Professionals can also make use of these tools to explore new language changes or to try out an unknown API.Mohamed Taman